diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-05-24 22:48:03 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-05-24 22:48:03 (GMT) |
commit | 62012fc719818b6087b01c93fcc1cd0d2b4d8932 (patch) | |
tree | 5104802fce85d89b4f2d186d38ec0b579f486237 /Lib/idlelib/dynOptionMenuWidget.py | |
parent | d383bafa556de686be4898d6544ce998a0812532 (diff) | |
download | cpython-62012fc719818b6087b01c93fcc1cd0d2b4d8932.zip cpython-62012fc719818b6087b01c93fcc1cd0d2b4d8932.tar.gz cpython-62012fc719818b6087b01c93fcc1cd0d2b4d8932.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 e81f7ba..133c6fd 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) |