diff options
author | Guido van Rossum <guido@python.org> | 2003-04-29 10:23:27 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-04-29 10:23:27 (GMT) |
commit | 57cd21fde285d25021ee978cd09ed58159166bf8 (patch) | |
tree | 57936b5a729c1219ae080d518832b9e17aa219ec /Tools/idle/dynOptionMenuWidget.py | |
parent | 19691360c7a8c203d1a94f6074036e810a6f0527 (diff) | |
download | cpython-57cd21fde285d25021ee978cd09ed58159166bf8.zip cpython-57cd21fde285d25021ee978cd09ed58159166bf8.tar.gz cpython-57cd21fde285d25021ee978cd09ed58159166bf8.tar.bz2 |
Checking in IDLEFORK exactly as it appears in the idlefork CVS.
On a branch, for now.
Diffstat (limited to 'Tools/idle/dynOptionMenuWidget.py')
-rw-r--r-- | Tools/idle/dynOptionMenuWidget.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Tools/idle/dynOptionMenuWidget.py b/Tools/idle/dynOptionMenuWidget.py new file mode 100644 index 0000000..e81f7ba --- /dev/null +++ b/Tools/idle/dynOptionMenuWidget.py @@ -0,0 +1,35 @@ +""" +OptionMenu widget modified to allow dynamic menu reconfiguration +and setting of highlightthickness +""" +from Tkinter import OptionMenu +from Tkinter import _setit +import copy + +class DynOptionMenu(OptionMenu): + """ + unlike OptionMenu, our kwargs can include highlightthickness + """ + def __init__(self, master, variable, value, *values, **kwargs): + #get a copy of kwargs before OptionMenu.__init__ munges them + kwargsCopy=copy.copy(kwargs) + if 'highlightthickness' in kwargs.keys(): + del(kwargs['highlightthickness']) + OptionMenu.__init__(self, master, variable, value, *values, **kwargs) + self.config(highlightthickness=kwargsCopy.get('highlightthickness')) + #self.menu=self['menu'] + self.variable=variable + self.command=kwargs.get('command') + + def SetMenu(self,valueList,value=None): + """ + clear and reload the menu with a new set of options. + valueList - list of new options + value - initial value to set the optionmenu's menubutton to + """ + self['menu'].delete(0,'end') + for item in valueList: + self['menu'].add_command(label=item, + command=_setit(self.variable,item,self.command)) + if value: + self.variable.set(value) |