MCPcopy Index your code
hub / github.com/python/cpython / DynOptionMenu

Class DynOptionMenu

Lib/idlelib/dynoption.py:7–30  ·  view source on GitHub ↗

Add SetMenu and highlightthickness to OptionMenu. Highlightthickness adds space around menu button.

Source from the content-addressed store, hash-verified

5from tkinter import OptionMenu, _setit, StringVar, Button
6
7class DynOptionMenu(OptionMenu):
8 """Add SetMenu and highlightthickness to OptionMenu.
9
10 Highlightthickness adds space around menu button.
11 """
12 def __init__(self, master, variable, value, *values, **kwargs):
13 highlightthickness = kwargs.pop('highlightthickness', None)
14 OptionMenu.__init__(self, master, variable, value, *values, **kwargs)
15 self['highlightthickness'] = highlightthickness
16 self.variable = variable
17 self.command = kwargs.get('command')
18
19 def SetMenu(self,valueList,value=None):
20 """
21 clear and reload the menu with a new set of options.
22 valueList - list of new options
23 value - initial value to set the optionmenu's menubutton to
24 """
25 self['menu'].delete(0,'end')
26 for item in valueList:
27 self['menu'].add_command(label=item,
28 command=_setit(self.variable,item,self.command))
29 if value:
30 self.variable.set(value)
31
32
33def _dyn_option_menu(parent): # htest #

Callers 4

create_page_fontMethod · 0.90
create_page_highlightMethod · 0.90
create_page_keysMethod · 0.90
_dyn_option_menuFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…