diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-05-24 22:48:18 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-05-24 22:48:18 (GMT) |
commit | 1b392ffe67febbe8740520289bb828fdf060e363 (patch) | |
tree | 27d5496ec5479afd9d1a36efcd02614315e7c447 /Lib/idlelib/dynOptionMenuWidget.py | |
parent | 10cbb1e463378391d2368874bb31af0447fa73e6 (diff) | |
download | cpython-1b392ffe67febbe8740520289bb828fdf060e363.zip cpython-1b392ffe67febbe8740520289bb828fdf060e363.tar.gz cpython-1b392ffe67febbe8740520289bb828fdf060e363.tar.bz2 |
Issue #21477: Idle htest: merge and modify run and runall; add many tests.
Patch by Saimadhav Heblikar
Diffstat (limited to 'Lib/idlelib/dynOptionMenuWidget.py')
-rw-r--r-- | Lib/idlelib/dynOptionMenuWidget.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Lib/idlelib/dynOptionMenuWidget.py b/Lib/idlelib/dynOptionMenuWidget.py index 922de96..877ca1b 100644 --- a/Lib/idlelib/dynOptionMenuWidget.py +++ b/Lib/idlelib/dynOptionMenuWidget.py @@ -2,9 +2,10 @@ OptionMenu widget modified to allow dynamic menu reconfiguration and setting of highlightthickness """ -from tkinter import OptionMenu -from tkinter import _setit +from tkinter import OptionMenu, _setit, Tk, StringVar, Button + import copy +import re class DynOptionMenu(OptionMenu): """ @@ -33,3 +34,24 @@ class DynOptionMenu(OptionMenu): command=_setit(self.variable,item,self.command)) if value: self.variable.set(value) + +def _dyn_option_menu(parent): + root = Tk() + root.title("Tets dynamic option menu") + var = StringVar(root) + width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) + root.geometry("+%d+%d"%(x, y + 150)) + var.set("Old option set") #Set the default value + dyn = DynOptionMenu(root,var, "old1","old2","old3","old4") + dyn.pack() + + def update(): + dyn.SetMenu(["new1","new2","new3","new4"],value="new option set") + + button = Button(root, text="Change option set", command=update) + button.pack() + root.mainloop() + +if __name__ == '__main__': + from idlelib.idle_test.htest import run + run(_dyn_option_menu) |