本文整理汇总了Python中Tkinter.OptionMenu方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.OptionMenu方法的具体用法?Python Tkinter.OptionMenu怎么用?Python Tkinter.OptionMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter
的用法示例。
在下文中一共展示了Tkinter.OptionMenu方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import OptionMenu [as 别名]
def __init__(self, master, variable, default=None, *values, **kw):
if platform == 'darwin':
variable.set(default)
bg = kw.pop('background', PAGEBG)
tk.OptionMenu.__init__(self, master, variable, *values, **kw)
self['background'] = bg
elif platform == 'win32':
# OptionMenu derives from Menubutton at the Python level, so uses Menubutton's style
ttk.OptionMenu.__init__(self, master, variable, default, *values, style='nb.TMenubutton', **kw)
self['menu'].configure(background = PAGEBG)
# Workaround for https://bugs.python.org/issue25684
for i in range(0, self['menu'].index('end')+1):
self['menu'].entryconfig(i, variable=variable)
else:
ttk.OptionMenu.__init__(self, master, variable, default, *values, **kw)
self['menu'].configure(background = ttk.Style().lookup('TMenu', 'background'))
# Workaround for https://bugs.python.org/issue25684
for i in range(0, self['menu'].index('end')+1):
self['menu'].entryconfig(i, variable=variable)
示例2: create
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import OptionMenu [as 别名]
def create(self, default='b', values=('a', 'b', 'c'), **kwargs):
return tkinter.OptionMenu(self.root, None, default, *values, **kwargs)
示例3: strap_design_frame_builder
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import OptionMenu [as 别名]
def strap_design_frame_builder(self):
self.strap_inputs_frame = tk.Frame(self.strap_design_frame)
self.strap_inputs_frame.pack(side=tk.LEFT, anchor='nw')
self.strap_calc_frame = tk.Frame(self.strap_design_frame)
self.strap_calc_frame.pack(side=tk.RIGHT ,anchor='ne', fill=tk.BOTH, expand=1)
tk.Label(self.strap_inputs_frame, text="B = ", font=self.helv).grid(row=0, column=0, sticky = tk.E)
tk.Entry(self.strap_inputs_frame, textvariable=self.bs, width=10, validate="key", validatecommand=self.reset_status).grid(row=0, column=1)
tk.Label(self.strap_inputs_frame, text="in", font=self.helv).grid(row=0, column=2)
tk.Label(self.strap_inputs_frame, text="H = ", font=self.helv).grid(row=1, column=0, sticky = tk.E)
tk.Entry(self.strap_inputs_frame, textvariable=self.hs, width=10, validate="key", validatecommand=self.reset_status).grid(row=1, column=1)
tk.Label(self.strap_inputs_frame, text="in", font=self.helv).grid(row=1, column=2)
self.strap_vbar_size = tk.StringVar()
self.inputs.append(self.strap_vbar_size)
self.strap_vbar_size.set('3')
self.strap_vbar_size_label = tk.Label(self.strap_inputs_frame, text="Shear\nBar Size (#) : ", font=self.helv)
self.strap_vbar_size_label.grid(row=2,column=0, pady=2)
self.strap_vbar_size_menu = tk.OptionMenu(self.strap_inputs_frame, self.strap_vbar_size, '3', '4', '5', command=self.reset_status)
self.strap_vbar_size_menu.config(font=self.helv)
self.strap_vbar_size_menu.grid(row=2, column=1, padx= 2, sticky=tk.W)
self.strap_bar_size = tk.StringVar()
self.inputs.append(self.strap_bar_size)
self.strap_bar_size.set('3')
self.strap_bar_size_label = tk.Label(self.strap_inputs_frame, text="Flexure\nBar Size (#) : ", font=self.helv)
self.strap_bar_size_label.grid(row=4,column=0, pady=2)
self.strap_bar_size_menu = tk.OptionMenu(self.strap_inputs_frame, self.strap_bar_size, '3', '4', '5','6','7','8','9','10','11','14','18', command=self.reset_status)
self.strap_bar_size_menu.config(font=self.helv)
self.strap_bar_size_menu.grid(row=4, column=1, padx= 2, sticky=tk.W)
self.strap_calc_txtbox = tk.Text(self.strap_calc_frame, height = 25, width = 70, bg= "grey90", font= self.helv_norm, wrap=tk.WORD)
self.strap_calc_txtbox.grid(row=0, column=0, sticky='nsew')
self.strap_scroll = tk.Scrollbar(self.strap_calc_frame, command=self.strap_calc_txtbox.yview)
self.strap_scroll.grid(row=0, column=1, sticky='nsew')
self.strap_calc_txtbox['yscrollcommand'] = self.strap_scroll.set
示例4: build_loads_gui
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import OptionMenu [as 别名]
def build_loads_gui(self, *event):
#Destroy all the individual tkinter gui elements for the current applied loads
for load_gui in self.loads_gui:
for gui_element in load_gui:
gui_element.destroy()
#Delete all the elements in the List containing the gui elements
del self.loads_gui[:]
del self.loads_scale[:]
n = 0
for loads in self.loads_gui_select_var:
load_types = ['Point','Moment','UDL','TRAP']
load_locals = ['Left','Center','Right']
if loads[6].get() == 'Moment':
self.loads_scale.append(float(loads[1].get())/2.0)
else:
self.loads_scale.append(float(loads[1].get()))
self.loads_scale.append(float(loads[2].get()))
self.loads_gui.append([
tk.Checkbutton(self.loads_frame, variable=loads[0], command = self.build_loads),
tk.Entry(self.loads_frame, textvariable=loads[1], width=15),
tk.Entry(self.loads_frame, textvariable=loads[2], width=15),
tk.Entry(self.loads_frame, textvariable=loads[3], width=15),
tk.Entry(self.loads_frame, textvariable=loads[4], width=15),
tk.OptionMenu(self.loads_frame, loads[5], *load_locals),
tk.OptionMenu(self.loads_frame, loads[6], *load_types)])
self.loads_gui[n][0].grid(row=n+1, column=1)
self.loads_gui[n][1].grid(row=n+1, column=2, padx = 4)
self.loads_gui[n][2].grid(row=n+1, column=3, padx = 4)
self.loads_gui[n][3].grid(row=n+1, column=4, padx = 4)
self.loads_gui[n][4].grid(row=n+1, column=5, padx = 4)
self.loads_gui[n][5].grid(row=n+1, column=6)
self.loads_gui[n][6].grid(row=n+1, column=7)
n+=1
示例5: shape_click
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import OptionMenu [as 别名]
def shape_click(self, *event):
shape = self.shape_menu.get(self.shape_menu.curselection())
shape_index = self.shape_types.index(self.shape_type.get())
section_props = self.shape_sets[shape_index].get(shape)
if section_props[0] == 'F':
self.data_frame.configure(text="Section Properties - AISC 14th Edition: -- Selected Shape: "+shape)
else:
note = self.shape_special_note[shape_index]
self.data_frame.configure(text="Section Properties - AISC 14th Edition: -- Selected Shape: "+shape+" -- Note: "+note)
for labels in self.properties_labels:
labels.configure( text=' ')
props_counter = 0
props_list = []
for i in range(1,len(self.values_list)):
if section_props[i] == '-':
pass
else:
if self.values_units[i] == '':
string = '{0}{1}:\n{2}'.format(self.values_list[i],self.values_units[i],section_props[i])
else:
string = '{0}({1}):\n{2}'.format(self.values_list[i],self.values_units[i],section_props[i])
props_list.append(self.values_list[i])
self.properties_labels[props_counter].configure( text=string)
props_counter+=1
self.value_def_menu.destroy()
self.value_def_menu = tk.OptionMenu(self.value_def_frame, self.value_def, *props_list, command=self.value_definitions)
helv = tkFont.Font(family='Helvetica',size=self.f_size, weight='bold')
self.value_def_menu.config(font=helv)
self.value_def_menu.grid(row=0, column=0, padx=1, pady=1)
self.value_def.set(props_list[0])
self.value_definitions()
示例6: edition_change
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import OptionMenu [as 别名]
def edition_change(self, *event):
self.shape_type_menu.destroy()
edition = self.edition_type.get()
edition_index = self.edition.index(edition)
self.shape_type_menu = tk.OptionMenu(self.menu_frame, self.shape_type, *self.shape_sets[edition_index], command=self.shape_change)
helv = tkFont.Font(family='Helvetica',size=self.f_size, weight='bold')
self.shape_type_menu.config(font=helv)
self.shape_type_menu.pack(side=tk.TOP, fill=tk.X, expand=True)
self.shape_type.set(self.shape_sets[edition_index][0])
示例7: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import OptionMenu [as 别名]
def __init__(self, master):
tk.Frame.__init__(self, master)
self.pack(padx=20, pady=20)
self.master = master
options = ['white', 'red', 'green', 'blue']
self.selection = tk.StringVar()
self.selection.set('White')
tk.Label(self, text="This is an optionmenu").pack()
tk.OptionMenu(self, self.selection, *[x.capitalize() for x in options], command=self.set_color).pack()
开发者ID:brysontyrrell,项目名称:MacAdmins-2016-Craft-GUIs-with-Python-and-Tkinter,代码行数:16,代码来源:Tkinter_Widget_Examples.py
示例8: addOption
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import OptionMenu [as 别名]
def addOption(self, master, title, options, value):
label = tk.Label(master, text=title)
label.grid(row=self.row, sticky=tk.W, column=self.labelColumn)
variable = tk.StringVar(master, value)
option = apply(tk.OptionMenu, (master, variable) + tuple(options))
option.grid(row=self.row, column=self.inputColumn, sticky=tk.W)
self.row += 1
return variable
示例9: addOption
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import OptionMenu [as 别名]
def addOption(self, master, title, options, value):
label = tk.Label(master, text=title)
label.grid(row=self.row, sticky=tk.W, column=self.labelColumn)
variable = tk.StringVar(master, value)
option = apply(tk.OptionMenu, (master, variable) + tuple(options))
option.grid(row=self.row, column=self.inputColumn, sticky=tk.W)
self.row += 1
return variable