当前位置: 首页>>代码示例>>Python>>正文


Python tkinter.OptionMenu方法代码示例

本文整理汇总了Python中tkinter.OptionMenu方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.OptionMenu方法的具体用法?Python tkinter.OptionMenu怎么用?Python tkinter.OptionMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter的用法示例。


在下文中一共展示了tkinter.OptionMenu方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import OptionMenu [as 别名]
def __init__(self, master, gui):
        super().__init__(master, text="output: Tremolo")
        self.gui = gui
        self.input_waveform = tk.StringVar()
        self.input_waveform.set("<off>")
        self.input_rate = tk.DoubleVar()
        self.input_depth = tk.DoubleVar()
        self.input_rate.set(5)
        self.input_depth.set(80)
        row = 0
        tk.Label(self, text="waveform").grid(row=row, column=0)
        values = ["<off>", "sine", "triangle", "sawtooth", "square"]
        menu = tk.OptionMenu(self, self.input_waveform, *values)
        menu["width"] = 10
        menu.grid(row=row, column=1)
        row += 1
        tk.Label(self, text="rate").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_rate, from_=0.0, to=10.0, resolution=.1,
                 width=10, length=100).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="depth").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_depth, from_=0.0, to=1.0, resolution=.02,
                 width=10, length=100).grid(row=row, column=1) 
开发者ID:irmen,项目名称:synthesizer,代码行数:25,代码来源:keyboard_gui.py

示例2: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import OptionMenu [as 别名]
def __init__(self):
        super().__init__()
        self.title("Fonts demo")
        text = "The quick brown fox jumps over the lazy dog"
        self.label = tk.Label(self, text=text)

        self.family = tk.StringVar()
        self.family.trace("w", self.set_font)
        families = ("Times", "Courier", "Helvetica")
        self.option = tk.OptionMenu(self, self.family, *families)

        self.size = tk.StringVar()
        self.size.trace("w", self.set_font)
        self.spinbox = tk.Spinbox(self, from_=8, to=18,
                                  textvariable=self.size)

        self.family.set(families[0])
        self.size.set("10")
        self.label.pack(padx=20, pady=20)
        self.option.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        self.spinbox.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) 
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Cookbook,代码行数:23,代码来源:chapter3_02.py

示例3: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import OptionMenu [as 别名]
def __init__(self, master):
        super().__init__(master, text="Line options")

        self.arrow = tk.StringVar()
        self.arrow.set(self.arrows[0])
        arrow_label = tk.Label(self, text="Arrow style")
        arrow_option = tk.OptionMenu(self, self.arrow, *self.arrows)

        self.color = tk.StringVar()
        self.color.set(self.colors[0])
        color_label = tk.Label(self, text="Fill color")
        color_option = tk.OptionMenu(self, self.color, *self.colors)

        line_width_label = tk.Label(self, text="Line width")
        self.line_width = tk.Spinbox(self, values=(1, 2, 3, 4), width=5)

        arrow_label.grid(sticky=tk.W, row=0, column=0)
        arrow_option.grid(row=0, column=1, pady=10)
        color_label.grid(sticky=tk.W, row=1, column=0)
        color_option.grid(row=1, column=1, pady=10)
        line_width_label.grid(sticky=tk.W, row=2, column=0)
        self.line_width.grid(row=2, column=1, pady=10) 
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Application-Development-Cookbook,代码行数:24,代码来源:chapter7_10.py

示例4: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import OptionMenu [as 别名]
def __init__(self, parent, options: list, initial_value: str = None,
                 callback: callable = None):
        super().__init__(parent)

        self._var = tk.StringVar()
        self._var.set(initial_value if initial_value else options[0])

        self.option_menu = tk.OptionMenu(self, self._var,
                                         *options)
        self.option_menu.grid(row=0, column=0)

        if callback is not None:
            def internal_callback(*args):
                try:
                    callback()
                except TypeError:
                    callback(self.get())
            self._var.trace('w', internal_callback) 
开发者ID:slightlynybbled,项目名称:tk_tools,代码行数:20,代码来源:widgets.py

示例5: 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:Microvellum,项目名称:Fluid-Designer,代码行数:4,代码来源:test_widgets.py

示例6: raise_dialogs_select_frame

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import OptionMenu [as 别名]
def raise_dialogs_select_frame(self):
        """Chooses a Telegram dialogue to analyse messages from."""
        table_frame = tk.Frame()
        table_frame.pack(expand=True, fill="both")

        dialog_select_label = tk.Label(table_frame, text="Please select a dialog You want to analyse messages from :",
                                       height=2, font=self.default_font)
        dialog_select_label.grid(row=1, column=1, sticky=tk.W)

        dialogs = await tlg.get_str_dialogs(loop=self.aio_loop)
        for i in range(len(dialogs)):
            dialogs[i] = ''.join(char for char in dialogs[i] if char < u"\uffff")

        dialog_variable = tk.StringVar()
        dialog_variable.set(dialogs[0])  # default value
        dialog_selection_menu = tk.OptionMenu(table_frame, dialog_variable, *dialogs)
        dialog_selection_menu.grid(row=2, column=1, sticky=tk.W)

        def select_dialog_and_continue():
            self.session_params["dialogue"] = dialog_variable.get()
            bottom_frame.destroy()
            table_frame.destroy()
            self.raise_finish_frame()

        bottom_frame = tk.Frame()
        bottom_frame.pack(side=tk.BOTTOM)
        continue_button = tk.Button(bottom_frame, text="Continue",
                                    command=select_dialog_and_continue, padx=35, background=self.button_background,
                                    font=self.default_font)
        continue_button.pack(side=tk.BOTTOM)
        self.parent.bind('<Return>', lambda _: select_dialog_and_continue()) 
开发者ID:vlajnaya-mol,项目名称:message-analyser,代码行数:33,代码来源:GUI.py

示例7: add_skills_selector

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import OptionMenu [as 别名]
def add_skills_selector(self, root, toolbar):
        label = ttk.Label(toolbar, text=u'Skills')
        label.pack(side=tk.LEFT, padx=2)

        self.selected_skills = tk.StringVar(root)
        self.selected_skills.set("")
        self.selected_skills.trace("w", self.on_skill_selected)
        self.selected_skills_dropmenu = tk.OptionMenu(toolbar, self.selected_skills, [])
        self.selected_skills_dropmenu.configure(state="disabled")
        self.selected_skills_dropmenu.pack(side=tk.LEFT, padx=2) 
开发者ID:IBM,项目名称:clai,代码行数:12,代码来源:clai_emulator.py

示例8: refresh_dropdown45

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import OptionMenu [as 别名]
def refresh_dropdown45(*args):
    global columns
    try:
        columns = pd.read_csv(e1.get(), sep=delimiter, nrows=1, encoding=e3.get(), engine="python").columns.values
        popupMenu4 = tk.OptionMenu(master, tkvar4, *columns)
        popupMenu4.grid(row=6, column=0, sticky=tk.E)
        popupMenu4.config(font=("Calibri", 12))
        popupMenu5 = tk.OptionMenu(master, tkvar5, *columns)
        popupMenu5.grid(row=7, column=0, sticky=tk.E)
        popupMenu5.config(font=("Calibri", 12))
        print("\nColumns loaded:")
        print("\n".join(columns))
        print("\nSelect columns and >>Web Scraper Settings<<")
    except:
        print("URL list could not be loaded.\nPlease browse for your file and select correct delimiter and encoding.") 
开发者ID:datawizard1337,项目名称:ARGUS,代码行数:17,代码来源:ARGUS.py

示例9: open_date_dlg

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import OptionMenu [as 别名]
def open_date_dlg(self):
        '''Open a popup for defining a range of dates
        '''
        self.custom_num_window = Tk.Toplevel()
        self.custom_num_window.withdraw()
        self.custom_num_window.title('{}: Date Selection'.format(self.title))
        self.custom_num_window.resizable(width=False, height=False)
        frame = Tk.Frame(self.custom_num_window)
        lb = Tk.Label(frame, text='Select Dates to {}'.format(self.title))
        lb.pack(fill='both', side='top')

        # Boxes for inputting the start and endpoints
        sp_box = Tk.Frame(frame)
        lb1 = Tk.Label(sp_box, text='From')
        lb1.pack(side='left', padx=5)
        cur_year = datetime.date.today().year
        self.sp_from = Tk.Spinbox(sp_box, width=12, from_=1950, to=cur_year)
        self.sp_from.pack(side='left')
        lb2 = Tk.Label(sp_box, text='To')
        lb2.pack(side='left', padx=(50, 5))
        var = Tk.IntVar()
        var.set(str(cur_year))
        self.sp_to = Tk.Spinbox(sp_box, width=12, from_=1950, to=cur_year, textvariable=var)
        self.sp_to.pack(side='right')
        sp_box.pack(fill='both', side='top', padx=30, pady=20)

        # Choose how the dates are formatted (mmddyyyy etc.)
        drop_down = Tk.OptionMenu(frame, self.date_format, *DATE_FORMATS)
        drop_down.configure(width=max(map(len, DATE_FORMATS)) + 4)
        self.date_format.set('mmddyy')
        drop_down.pack(side='top')
        
        self.date_zero_padding = Tk.IntVar()
        checkbutton = Tk.Checkbutton(frame, text='Leading zero on single-digit d or m', relief=Tk.FLAT, variable=self.date_zero_padding)
        checkbutton.pack()
        
        # Ok and cancel buttons
        btn_box = Tk.Frame(frame)
        btn_cancel = Tk.Button(btn_box, text='Cancel', command=self.cancel_custom_num_window)
        btn_cancel.pack(side='right', padx=10, pady=20)
        btn_ok = Tk.Button(btn_box, text='Ok', command=self.on_ok_date_window)
        btn_ok.pack(side='left', padx=10, pady=20)
        btn_box.pack()
        
        frame.pack(fill='both', padx=10, pady=10)
        
        center_window(self.custom_num_window, self.main.master)
        self.custom_num_window.focus_set() 
开发者ID:sc0tfree,项目名称:mentalist,代码行数:50,代码来源:adder.py

示例10: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import OptionMenu [as 别名]
def __init__(self, pid_gui, scf):
        self.cf = scf
        self.pid_gui = pid_gui

        self.label = tk.Label(self.pid_gui.master, text='Choose an axis!')
        self.label.pack()
        variable = tk.StringVar(self.pid_gui.master)
        variable.set('z')
        self.dropdown = tk.OptionMenu(
            self.pid_gui.master, variable, 'x', 'y', 'z',
            command=self.change_param_callback)
        self.dropdown.pack()
        self.axis_choice = 'z'

        self.button_send = tk.Button(
            self.pid_gui.master, text='SEND PID GAINS',
            command=self.send_pid_gains).pack()
        self.button_step = tk.Button(
            self.pid_gui.master, text='DO STEP',
            command=self.do_step).pack()
        self.button_quit = tk.Button(
            self.pid_gui.master, text='STOP',
            command=self.stop_gui).pack()

        self.cf.param.add_update_callback(
            group='posCtlPid', name='zKp', cb=self.param_updated_callback_Kp)
        self.cf.param.add_update_callback(
            group='posCtlPid', name='zKi', cb=self.param_updated_callback_Ki)
        self.cf.param.add_update_callback(
            group='posCtlPid', name='zKd', cb=self.param_updated_callback_Kd)

        self.current_value_kp = 0
        self.current_value_kd = 0
        self.current_value_ki = 0

        self.cf.param.request_param_update('posCtlPid.zKp')
        self.cf.param.request_param_update('posCtlPid.zKi')
        self.cf.param.request_param_update('posCtlPid.zKd')

        time.sleep(0.1)

        self.update_scale_info()

        self.commander = cf.high_level_commander
        self.cf.param.set_value('commander.enHighLevel', '1')
        self.take_off(STANDARD_HEIGHT) 
开发者ID:bitcraze,项目名称:crazyflie-lib-python,代码行数:48,代码来源:PID_controller_tuner.py

示例11: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import OptionMenu [as 别名]
def __init__(self):
        self.specs = SystemSpecs()
        self.form_instructions = FormInstructions(self.specs)
        self.asset_qr = AssetQRCode()

        self.root_window = Tk()
        self.root_window.title('InQRy')

        self.form_options_label = Label(self.root_window, text='Form Factor:')
        self.form_options_label.grid(row=1, column=1, sticky=E)

        self.form_options = tuple(self.form_instructions.form_types.keys())[0:2]
        self.form_selection = StringVar()
        self.form_selection.set(self.form_options[0])
        self.form_menu = OptionMenu(self.root_window, self.form_selection, *self.form_options)
        self.form_menu.grid(row=1, column=2, sticky=W)

        self.qrcode_options_label = Label(self.root_window, text='QR Code Type:')
        self.qrcode_options_label.grid(row=2, column=1, sticky=E)

        self.qrcode_options = ['Create Asset', 'New Model']
        self.qrcode_selection = StringVar()
        self.qrcode_selection.set(self.qrcode_options[0])
        self.qrcode_menu = OptionMenu(self.root_window, self.qrcode_selection, *self.qrcode_options)
        self.qrcode_menu.grid(row=2, column=2, sticky=W)

        self.alias_label = Label(self.root_window, text='Alias:')
        self.alias_label.grid(row=3, column=1, sticky=E)

        self.alias_entry = Entry(self.root_window)
        self.alias_entry.grid(row=3, column=2)

        self.asset_tag_label = Label(self.root_window, text='Asset Tag:')
        self.asset_tag_label.grid(row=4, column=1, sticky=E)

        self.asset_tag_entry = Entry(self.root_window)
        self.asset_tag_entry.grid(row=4, column=2)

        # Instantiate the "Show" button for door-to-door inventory
        self.generate_qr_button = Button(self.root_window, text='Show QR Code', command=self.display)
        self.generate_qr_button.grid(row=5, column=1)

        self.generate_qr_button = Button(self.root_window, text='Save QR Code to Desktop', command=self.save)
        self.generate_qr_button.grid(row=5, column=2) 
开发者ID:microsoft,项目名称:InQRy,代码行数:46,代码来源:gui.py


注:本文中的tkinter.OptionMenu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。