Python tkinter.ttk.Combobox() Examples
The following are 30
code examples of tkinter.ttk.Combobox().
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.ttk
, or try the search function
.
Example #1
Source File: components.py From SEM with MIT License | 8 votes |
def __init__(self, root, resource_dir): ttk.Frame.__init__(self, root) self.master_selector = None self.resource_dir = resource_dir self.items = os.listdir(os.path.join(self.resource_dir, "master")) self.cur_lang = tkinter.StringVar() self.select_lang_label = ttk.Label(root, text=u"select language:") self.langs = ttk.Combobox(root, textvariable=self.cur_lang) self.langs["values"] = self.items self.langs.current(0) for i, item in enumerate(self.items): if item == "fr": self.langs.current(i) self.langs.bind("<<ComboboxSelected>>", self.select_lang)
Example #2
Source File: OptionPane.py From Endless-Sky-Mission-Builder with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent): ttk.Frame.__init__(self, parent) logging.debug("\tInitializing OptionPane...") self.mfi = config.mission_file_items self.option_frame = self title = ttk.Label(self.option_frame, text="Mission File Items") title.pack() item_names = self.mfi.get_names() self.combo_box = ttk.Combobox(self.option_frame, state="readonly", values=item_names) self.combo_box.bind("<<ComboboxSelected>>", self.item_selected) self.combo_box.pack() if config.debugging: self.combo_box.current(0) self.add_buttons() #end init
Example #3
Source File: load_xls_gui.py From pyDEA with MIT License | 6 votes |
def create_widgets(self, names): ''' Creates appropriate widgets. Args: names (list of str): list of available sheet names. ''' sheet_name_lbl = Label(self, text='Choose sheet name where data is stored:') sheet_name_lbl.grid(sticky=N+W, padx=5, pady=5) sheet_names_box = Combobox(self, state="readonly", width=20, textvariable=self.sheet_name_str, values=names) sheet_names_box.current(0) sheet_names_box.grid(row=1, column=0, columnspan=2, sticky=N+W, padx=5, pady=5) ok_btn = Button(self, text='OK', command=self.ok) ok_btn.grid(row=2, column=0, sticky=N+E, padx=5, pady=5) ok_btn.bind('<Return>', self.ok) ok_btn.focus() cancel_btn = Button(self, text='Cancel', command=self.cancel) cancel_btn.grid(row=2, column=1, sticky=N+E, padx=5, pady=5) cancel_btn.bind('<Return>', self.cancel)
Example #4
Source File: EditableTreeview.py From PyEngine3D with BSD 2-Clause "Simplified" License | 6 votes |
def inplace_combobox(self, col, item, values, readonly=True): self.clear_inplace_widgets() self._inplace_item = item state = 'readonly' if readonly else 'normal' self._inplace_var = tk.StringVar() svar = self._inplace_var svar.set(self.__get_value(col, item)) self._inplace_widget = ttk.Combobox(self, textvariable=svar, state=state) self._inplace_widget.configure(values=values) cb = self._inplace_widget # cb.bind('<Return>', lambda e: self.__update_value(col, item)) # cb.bind('<Unmap>', lambda e: self.__update_value(col, item)) # cb.bind('<FocusOut>', lambda e: self.__update_value(col, item)) cb.bind("<<ComboboxSelected>>", lambda e: self.__update_value(col, item), "+") self.__updateWnds(col, item, cb)
Example #5
Source File: pykms_GuiBase.py From py-kms with The Unlicense | 6 votes |
def clt_eject(self): while self.clientthread.is_alive(): sleep(0.1) widgets = self.storewidgets_clt + [self.runbtnclt] if not self.onlyclt: widgets += [self.runbtnsrv] for widget in widgets: if isinstance(widget, ttk.Combobox): widget.configure(state = 'readonly') else: widget.configure(state = 'normal') if isinstance(widget, ListboxOfRadiobuttons): widget.change()
Example #6
Source File: main.py From tkinter-logging-text-widget with BSD 2-Clause "Simplified" License | 6 votes |
def __init__(self, frame): self.frame = frame # Create a combobbox to select the logging level values = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] self.level = tk.StringVar() ttk.Label(self.frame, text='Level:').grid(column=0, row=0, sticky=W) self.combobox = ttk.Combobox( self.frame, textvariable=self.level, width=25, state='readonly', values=values ) self.combobox.current(0) self.combobox.grid(column=1, row=0, sticky=(W, E)) # Create a text field to enter a message self.message = tk.StringVar() ttk.Label(self.frame, text='Message:').grid(column=0, row=1, sticky=W) ttk.Entry(self.frame, textvariable=self.message, width=25).grid(column=1, row=1, sticky=(W, E)) # Add a button to log the message self.button = ttk.Button(self.frame, text='Submit', command=self.submit_message) self.button.grid(column=1, row=2, sticky=W)
Example #7
Source File: ComboComponentFrame.py From Endless-Sky-Mission-Builder with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent, component_name, list_combobox_data, tooltip_key): ttk.Frame.__init__(self, parent) self.columnconfigure(0, weight=1) logging.debug("\t\tBuilding \"%s\"" % component_name) label = widgets.TooltipLabel(self, tooltip_key, text=component_name) label.grid(row=0, column=0, sticky="w", padx=(5, 0)) self.listComboboxData = list_combobox_data self.is_active = BooleanVar() self.option = None self.button = ttk.Checkbutton(self, onvalue=1, offvalue=0, variable=self.is_active) self.combo = ttk.Combobox(self, state="disabled", values=self.listComboboxData, style='D.TCombobox') self.combo.bind("<<ComboboxSelected>>", self.option_selected) self.button.configure(command=partial(self._cb_value_changed, self.is_active, [self.combo])) self.button.grid(row=0, column=1, sticky="e") self.combo.grid(row=1, column=0, sticky="ew", padx=(20,0)) #end init
Example #8
Source File: TypeSelectorWindow.py From Endless-Sky-Mission-Builder with GNU General Public License v3.0 | 6 votes |
def __init__(self, master, options, callback, **kwargs): self.callback = callback super().__init__(master, **kwargs) self.option_list = ttk.Combobox(self, values=options, state="readonly", width=25) self.option_list.current(0) self.option_list.pack() buttons = ttk.Frame(self) ok = ttk.Button(buttons, text="OK", command=self._cleanup) ok.pack(side=LEFT, fill="x") cxl = ttk.Button(buttons, text="Cancel", command=self._cancelled) cxl.pack(fill="x") buttons.pack() # these commands make the parent window inactive self.transient(master) self.grab_set() master.wait_window(self) #end init
Example #9
Source File: control_helper.py From faceswap with GNU General Public License v3.0 | 6 votes |
def get_control(self): """ Set the correct control type based on the datatype or for this option """ if self.choices and self.is_radio: control = "radio" elif self.choices and self.is_multi_option: control = "multi" elif self.choices and self.choices == "colorchooser": control = "colorchooser" elif self.choices: control = ttk.Combobox elif self.dtype == bool: control = ttk.Checkbutton elif self.dtype in (int, float): control = "scale" else: control = ttk.Entry logger.debug("Setting control '%s' to %s", self.title, control) return control
Example #10
Source File: 6.09.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_number_of_spokes_options_combobox(self): tk.Label(self.top_bar, text='Number of Edges:').pack(side="left") self.number_of_spokes_combobox = ttk.Combobox( self.top_bar, state='readonly', width=3) self.number_of_spokes_combobox.pack(side="left") self.number_of_spokes_combobox[ 'values'] = tuple(i for i in range(5, 50)) self.number_of_spokes_combobox.bind( '<<ComboboxSelected>>', self.set_number_of_spokes) self.number_of_spokes_combobox.set(self.number_of_spokes)
Example #11
Source File: display_analysis.py From faceswap with GNU General Public License v3.0 | 5 votes |
def opts_combobox(self, frame): """ Add the options combo boxes """ logger.debug("Building Combo boxes") choices = {"Display": ("Loss", "Rate"), "Scale": ("Linear", "Log")} for item in ["Display", "Scale"]: var = tk.StringVar() cmbframe = ttk.Frame(frame) cmbframe.pack(fill=tk.X, pady=5, padx=5, side=tk.TOP) lblcmb = ttk.Label(cmbframe, text="{}:".format(item), width=7, anchor=tk.W) lblcmb.pack(padx=(0, 2), side=tk.LEFT) cmb = ttk.Combobox(cmbframe, textvariable=var, width=10) cmb["values"] = choices[item] cmb.current(0) cmb.pack(fill=tk.X, side=tk.RIGHT) cmd = self.optbtn_reload if item == "Display" else self.graph_scale var.trace("w", cmd) self.vars[item.lower().strip()] = var hlp = self.set_help(item) Tooltip(cmbframe, text=hlp, wraplength=200) logger.debug("Built Combo boxes")
Example #12
Source File: rec_gui.py From python-sounddevice with MIT License | 5 votes |
def body(self, master): ttk.Label(master, text='Select host API:').pack(anchor='w') hostapi_list = ttk.Combobox(master, state='readonly', width=50) hostapi_list.pack() hostapi_list['values'] = [hostapi['name'] for hostapi in sd.query_hostapis()] ttk.Label(master, text='Select sound device:').pack(anchor='w') device_ids = [] device_list = ttk.Combobox(master, state='readonly', width=50) device_list.pack() def update_device_list(*args): hostapi = sd.query_hostapis(hostapi_list.current()) nonlocal device_ids device_ids = [ idx for idx in hostapi['devices'] if sd.query_devices(idx)['max_output_channels'] > 0] device_list['values'] = [ sd.query_devices(idx)['name'] for idx in device_ids] default = hostapi['default_output_device'] if default >= 0: device_list.current(device_ids.index(default)) device_list.event_generate('<<ComboboxSelected>>') def select_device(*args): self.result = device_ids[device_list.current()] hostapi_list.bind('<<ComboboxSelected>>', update_device_list) device_list.bind('<<ComboboxSelected>>', select_device) with contextlib.suppress(sd.PortAudioError): hostapi_list.current(sd.default.hostapi) hostapi_list.event_generate('<<ComboboxSelected>>')
Example #13
Source File: GUI_Not_OOP.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 5 votes |
def createWidgets(): tabControl = ttk.Notebook(win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") monty = ttk.LabelFrame(tab1, text=' Mighty Python ') monty.grid(column=0, row=0, padx=8, pady=4) ttk.Label(monty, text="Enter a name:").grid(column=0, row=0, sticky='W') name = tk.StringVar() nameEntered = ttk.Entry(monty, width=12, textvariable=name) nameEntered.grid(column=0, row=1, sticky='W') action = ttk.Button(monty, text="Click Me!") action.grid(column=2, row=1) ttk.Label(monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(monty, width=12, textvariable=number) numberChosen['values'] = (42) numberChosen.grid(column=1, row=1) numberChosen.current(0) scrolW = 30; scrolH = 3 scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD) scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) nameEntered.focus() #======================
Example #14
Source File: GUI_MySQL.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 5 votes |
def defaultFileEntries(self): self.fileEntry.delete(0, tk.END) self.fileEntry.insert(0, 'Z:\\') # bogus path self.fileEntry.config(state='readonly') self.netwEntry.delete(0, tk.END) self.netwEntry.insert(0, 'Z:\\Backup') # bogus path # Combobox callback
Example #15
Source File: GUI.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 5 votes |
def defaultFileEntries(self): self.fileEntry.delete(0, tk.END) self.fileEntry.insert(0, 'Z:\\') # bogus path self.fileEntry.config(state='readonly') self.netwEntry.delete(0, tk.END) self.netwEntry.insert(0, 'Z:\\Backup') # bogus path # Combobox callback
Example #16
Source File: GUI_OOP.py From Python-GUI-Programming-Cookbook-Third-Edition with MIT License | 5 votes |
def createWidgets(self): tabControl = ttk.Notebook(self.win) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text='Tab 1') tabControl.pack(expand=1, fill="both") self.monty = ttk.LabelFrame(tab1, text=' Mighty Python ') self.monty.grid(column=0, row=0, padx=8, pady=4) ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W') self.name = tk.StringVar() nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name) nameEntered.grid(column=0, row=1, sticky='W') self.action = ttk.Button(self.monty, text="Click Me!") self.action.grid(column=2, row=1) ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() numberChosen = ttk.Combobox(self.monty, width=12, textvariable=number) numberChosen['values'] = (42) numberChosen.grid(column=1, row=1) numberChosen.current(0) scrolW = 30; scrolH = 3 self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD) self.scr.grid(column=0, row=3, sticky='WE', columnspan=3) menuBar = Menu(tab1) self.win.config(menu=menuBar) fileMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="File", menu=fileMenu) helpMenu = Menu(menuBar, tearoff=0) menuBar.add_cascade(label="Help", menu=helpMenu) nameEntered.focus() #==========================
Example #17
Source File: 6.08.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_number_of_spokes_options_combobox(self): tk.Label(self.top_bar, text='Number of Edges:').pack(side="left") self.number_of_spokes_combobox = ttk.Combobox( self.top_bar, state='readonly', width=3) self.number_of_spokes_combobox.pack(side="left") self.number_of_spokes_combobox[ 'values'] = tuple(i for i in range(5, 50)) self.number_of_spokes_combobox.bind( '<<ComboboxSelected>>', self.set_number_of_spokes) self.number_of_spokes_combobox.set(self.number_of_spokes)
Example #18
Source File: 6.08.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_fill_options_combobox(self): tk.Label(self.top_bar, text='Fill:').pack(side="left") self.fill_combobox = ttk.Combobox( self.top_bar, state='readonly', width=5) self.fill_combobox.pack(side="left") self.fill_combobox['values'] = ('none', 'fg', 'bg', 'black', 'white') self.fill_combobox.bind('<<ComboboxSelected>>', self.set_fill) self.fill_combobox.set(self.fill)
Example #19
Source File: 6.08.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_super_shapes_options_combobox(self): tk.Label(self.top_bar, text='Select shape:').pack(side="left") self.super_shape_combobox = ttk.Combobox( self.top_bar, state='readonly', width=8) self.super_shape_combobox.pack(side="left") self.super_shape_combobox['values'] = tuple( shape for shape in super_shapes.keys()) self.super_shape_combobox.bind( '<<ComboboxSelected>>', self.set_selected_super_shape) self.super_shape_combobox.set(self.selected_super_shape)
Example #20
Source File: 6.09.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_arrow_options_combobox(self): tk.Label(self.top_bar, text='Arrow:').pack(side="left") self.arrow_combobox = ttk.Combobox( self.top_bar, state='readonly', width=5) self.arrow_combobox.pack(side="left") self.arrow_combobox['values'] = ('none', 'first', 'last', 'both') self.arrow_combobox.bind('<<ComboboxSelected>>', self.set_arrow) self.arrow_combobox.current(0)
Example #21
Source File: 6.09.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_width_options_combobox(self): tk.Label(self.top_bar, text='Width:').pack(side="left") self.width_combobox = ttk.Combobox( self.top_bar, state='readonly', width=3) self.width_combobox.pack(side="left") self.width_combobox['values'] = ( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0) self.width_combobox.bind('<<ComboboxSelected>>', self.set_width) self.width_combobox.set(self.width)
Example #22
Source File: 6.09.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_outline_options_combobox(self): tk.Label(self.top_bar, text='Outline:').pack(side="left") self.outline_combobox = ttk.Combobox( self.top_bar, state='readonly', width=5) self.outline_combobox.pack(side="left") self.outline_combobox['values'] = ( 'none', 'fg', 'bg', 'black', 'white') self.outline_combobox.bind('<<ComboboxSelected>>', self.set_outline) self.outline_combobox.set(self.outline)
Example #23
Source File: 6.09.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_fill_options_combobox(self): tk.Label(self.top_bar, text='Fill:').pack(side="left") self.fill_combobox = ttk.Combobox( self.top_bar, state='readonly', width=5) self.fill_combobox.pack(side="left") self.fill_combobox['values'] = ('none', 'fg', 'bg', 'black', 'white') self.fill_combobox.bind('<<ComboboxSelected>>', self.set_fill) self.fill_combobox.set(self.fill)
Example #24
Source File: 6.06.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_fill_options_combobox(self): tk.Label(self.top_bar, text='Fill:').pack(side="left") self.fill_combobox = ttk.Combobox( self.top_bar, state='readonly', width=5) self.fill_combobox.pack(side="left") self.fill_combobox['values'] = ('none', 'fg', 'bg', 'black', 'white') self.fill_combobox.bind('<<ComboboxSelected>>', self.set_fill) self.fill_combobox.set(self.fill)
Example #25
Source File: 6.09.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_super_shapes_options_combobox(self): tk.Label(self.top_bar, text='Select shape:').pack(side="left") self.super_shape_combobox = ttk.Combobox( self.top_bar, state='readonly', width=8) self.super_shape_combobox.pack(side="left") self.super_shape_combobox['values'] = tuple( shape for shape in super_shapes.keys()) self.super_shape_combobox.bind( '<<ComboboxSelected>>', self.set_selected_super_shape) self.super_shape_combobox.set(self.selected_super_shape)
Example #26
Source File: 6.06.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_dash_options_combobox(self): tk.Label(self.top_bar, text='Dash:').pack(side="left") self.dash_combobox = ttk.Combobox( self.top_bar, state='readonly', width=5) self.dash_combobox.pack(side="left") self.dash_combobox['values'] = ('none', 'small', 'medium', 'large') self.dash_combobox.bind('<<ComboboxSelected>>', self.set_dash) self.dash_combobox.current(0)
Example #27
Source File: 6.06.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_width_options_combobox(self): tk.Label(self.top_bar, text='Width:').pack(side="left") self.width_combobox = ttk.Combobox( self.top_bar, state='readonly', width=3) self.width_combobox.pack(side="left") self.width_combobox['values'] = ( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0) self.width_combobox.bind('<<ComboboxSelected>>', self.set_width) self.width_combobox.set(self.width)
Example #28
Source File: 6.06.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_outline_options_combobox(self): tk.Label(self.top_bar, text='Outline:').pack(side="left") self.outline_combobox = ttk.Combobox( self.top_bar, state='readonly', width=5) self.outline_combobox.pack(side="left") self.outline_combobox['values'] = ( 'none', 'fg', 'bg', 'black', 'white') self.outline_combobox.bind('<<ComboboxSelected>>', self.set_outline) self.outline_combobox.set(self.outline)
Example #29
Source File: 6.06.py From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License | 5 votes |
def create_number_of_spokes_options_combobox(self): tk.Label(self.top_bar, text='Number of Edges:').pack(side="left") self.number_of_spokes_combobox = ttk.Combobox( self.top_bar, state='readonly', width=3) self.number_of_spokes_combobox.pack(side="left") self.number_of_spokes_combobox[ 'values'] = tuple(i for i in range(5, 50)) self.number_of_spokes_combobox.bind( '<<ComboboxSelected>>', self.set_number_of_spokes) self.number_of_spokes_combobox.set(self.number_of_spokes)
Example #30
Source File: test_widgets.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def create(self, **kwargs): return ttk.Combobox(self.root, **kwargs)