當前位置: 首頁>>代碼示例>>Python>>正文


Python Tkinter.OptionMenu方法代碼示例

本文整理匯總了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) 
開發者ID:EDCD,項目名稱:EDMarketConnector,代碼行數:21,代碼來源:myNotebook.py

示例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) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:4,代碼來源:test_widgets.py

示例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 
開發者ID:buddyd16,項目名稱:Structural-Engineering,代碼行數:41,代碼來源:strap_beam_gui.py

示例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 
開發者ID:buddyd16,項目名稱:Structural-Engineering,代碼行數:40,代碼來源:simple_beam_metric.py

示例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() 
開發者ID:buddyd16,項目名稱:Structural-Engineering,代碼行數:37,代碼來源:aisc_steel_shapes.py

示例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]) 
開發者ID:buddyd16,項目名稱:Structural-Engineering,代碼行數:11,代碼來源:aisc_steel_shapes_historic.py

示例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 
開發者ID:PCWG,項目名稱:PCWG,代碼行數:15,代碼來源:pcwg_tool_reborn.py

示例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 
開發者ID:PCWG,項目名稱:PCWG,代碼行數:15,代碼來源:base_dialog.py


注:本文中的Tkinter.OptionMenu方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。