diff options
| author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-05-25 22:44:05 (GMT) | 
|---|---|---|
| committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-05-25 22:44:05 (GMT) | 
| commit | a2fc99eceae7b3dacc1e7280cc01c3b877ce55ab (patch) | |
| tree | c6593cf545a51196117abd00623081007bf2ce67 /Lib/idlelib/Percolator.py | |
| parent | e1d54e5f8e63cf8a464a1c4c3d42e4f3a107b83f (diff) | |
| download | cpython-a2fc99eceae7b3dacc1e7280cc01c3b877ce55ab.zip cpython-a2fc99eceae7b3dacc1e7280cc01c3b877ce55ab.tar.gz cpython-a2fc99eceae7b3dacc1e7280cc01c3b877ce55ab.tar.bz2  | |
Issue #21477: Idle htest: modify run; add more tests.
Patch by Saimadhav Heblikar. 2.7 version will follow.
Diffstat (limited to 'Lib/idlelib/Percolator.py')
| -rw-r--r-- | Lib/idlelib/Percolator.py | 50 | 
1 files changed, 35 insertions, 15 deletions
diff --git a/Lib/idlelib/Percolator.py b/Lib/idlelib/Percolator.py index c91de38..9e93319 100644 --- a/Lib/idlelib/Percolator.py +++ b/Lib/idlelib/Percolator.py @@ -51,8 +51,9 @@ class Percolator:              f.setdelegate(filter.delegate)              filter.setdelegate(None) -def main(): -    import tkinter as Tk +def _percolator(parent): +    import tkinter as tk +    import re      class Tracer(Delegator):          def __init__(self, name):              self.name = name @@ -63,22 +64,41 @@ def main():          def delete(self, *args):              print(self.name, ": delete", args)              self.delegate.delete(*args) -    root = Tk.Tk() -    root.wm_protocol("WM_DELETE_WINDOW", root.quit) -    text = Tk.Text() -    text.pack() -    text.focus_set() +    root = tk.Tk() +    root.title("Test Percolator") +    width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) +    root.geometry("+%d+%d"%(x, y + 150)) +    text = tk.Text(root)      p = Percolator(text)      t1 = Tracer("t1")      t2 = Tracer("t2") -    p.insertfilter(t1) -    p.insertfilter(t2) -    root.mainloop() # click close widget to continue... -    p.removefilter(t2) -    root.mainloop() -    p.insertfilter(t2) -    p.removefilter(t1) + +    def toggle1(): +        if var1.get() == 0: +            var1.set(1) +            p.insertfilter(t1) +        elif var1.get() == 1: +            var1.set(0) +            p.removefilter(t1) + +    def toggle2(): +        if var2.get() == 0: +            var2.set(1) +            p.insertfilter(t2) +        elif var2.get() == 1: +            var2.set(0) +            p.removefilter(t2) + +    text.pack() +    var1 = tk.IntVar() +    cb1 = tk.Checkbutton(root, text="Tracer1", command=toggle1, variable=var1) +    cb1.pack() +    var2 = tk.IntVar() +    cb2 = tk.Checkbutton(root, text="Tracer2", command=toggle2, variable=var2) +    cb2.pack() +      root.mainloop()  if __name__ == "__main__": -    main() +    from idlelib.idle_test.htest import run +    run(_percolator)  | 
