Python tkinter.OptionMenu() Examples

The following are 15 code examples of tkinter.OptionMenu(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkinter , or try the search function .
Example #1
Source File: keyboard_gui.py    From synthesizer with GNU Lesser General Public License v3.0 7 votes vote down vote up
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) 
Example #2
Source File: chapter3_02.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 6 votes vote down vote up
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) 
Example #3
Source File: chapter7_10.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 6 votes vote down vote up
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) 
Example #4
Source File: chapter7_02.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 6 votes vote down vote up
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) 
Example #5
Source File: widgets.py    From tk_tools with MIT License 6 votes vote down vote up
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) 
Example #6
Source File: test_widgets.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def create(self, default='b', values=('a', 'b', 'c'), **kwargs):
        return tkinter.OptionMenu(self.root, None, default, *values, **kwargs) 
Example #7
Source File: GUI.py    From message-analyser with MIT License 5 votes vote down vote up
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()) 
Example #8
Source File: test_widgets.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def create(self, default='b', values=('a', 'b', 'c'), **kwargs):
        return tkinter.OptionMenu(self.root, None, default, *values, **kwargs) 
Example #9
Source File: clai_emulator.py    From clai with MIT License 5 votes vote down vote up
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) 
Example #10
Source File: keyboard_gui.py    From synthesizer with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, master, name, gui):
        super().__init__(master, text="ADSR Envelope "+name)
        self.input_source = tk.StringVar()
        self.input_attack = tk.DoubleVar()
        self.input_attack.set(0.05)
        self.input_decay = tk.DoubleVar()
        self.input_decay.set(0.5)
        self.input_sustain = tk.DoubleVar()
        self.input_sustain.set(0.6)
        self.input_sustain_level = tk.DoubleVar()
        self.input_sustain_level.set(0.5)
        self.input_release = tk.DoubleVar()
        self.input_release.set(0.6)
        row = 0
        tk.Label(self, text="apply to").grid(row=row, column=0, sticky=tk.E)
        values = ["<none>", "osc 1", "osc 2", "osc 3", "osc 4", "osc 5"]
        menu = tk.OptionMenu(self, self.input_source, *values)
        menu["width"] = 10
        menu.grid(row=row, column=1)
        row += 1
        tk.Label(self, text="attack").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_attack, from_=0, to=2.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="decay").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_decay, from_=0, to=2.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="sustain").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_sustain, from_=0.0, to=2.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="sustain lvl").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_sustain_level, from_=0.0, to=1.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        row += 1
        tk.Label(self, text="release").grid(row=row, column=0, sticky=tk.E)
        tk.Scale(self, orient=tk.HORIZONTAL, variable=self.input_release, from_=0.0, to=2.0, resolution=.01,
                 width=10, length=120).grid(row=row, column=1)
        self.input_source.set("<none>") 
Example #11
Source File: test_widgets.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def create(self, default='b', values=('a', 'b', 'c'), **kwargs):
        return tkinter.OptionMenu(self.root, None, default, *values, **kwargs) 
Example #12
Source File: ARGUS.py    From ARGUS with GNU General Public License v3.0 5 votes vote down vote up
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.") 
Example #13
Source File: adder.py    From mentalist with MIT License 4 votes vote down vote up
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() 
Example #14
Source File: PID_controller_tuner.py    From crazyflie-lib-python with GNU General Public License v2.0 4 votes vote down vote up
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) 
Example #15
Source File: gui.py    From InQRy with MIT License 4 votes vote down vote up
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)