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 vote down vote up
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: EditableTreeview.py    From PyEngine3D with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #3
Source File: load_xls_gui.py    From pyDEA with MIT License 6 votes vote down vote up
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: main.py    From tkinter-logging-text-widget with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #5
Source File: control_helper.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
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 #6
Source File: ComboComponentFrame.py    From Endless-Sky-Mission-Builder with GNU General Public License v3.0 6 votes vote down vote up
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 #7
Source File: TypeSelectorWindow.py    From Endless-Sky-Mission-Builder with GNU General Public License v3.0 6 votes vote down vote up
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 #8
Source File: OptionPane.py    From Endless-Sky-Mission-Builder with GNU General Public License v3.0 6 votes vote down vote up
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 #9
Source File: components.py    From SEM with MIT License 5 votes vote down vote up
def __init__(self, root):
        ttk.Frame.__init__(self, root)
        
        self.root = root
        self.label = ttk.Label(self.root, text=u"select output format:")
        
        self.export_formats = ["default"] + [exporter[:-3] for exporter in os.listdir(os.path.join(sem.SEM_HOME, "exporters")) if (exporter.endswith(".py") and not exporter.startswith("_") and not exporter == "exporter.py")]
        self.export_combobox = ttk.Combobox(self.root)
        self.export_combobox["values"] = self.export_formats
        self.export_combobox.current(0) 
Example #10
Source File: Main.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_widgets(self):
        self.currencyFromCombobox = ttk.Combobox(self,
                textvariable=self.currencyFrom)
        self.currencyToCombobox = ttk.Combobox(self,
                textvariable=self.currencyTo)
        self.amountSpinbox = Spinbox(self, textvariable=self.amount,
                from_=1.0, to=10e6, validate="all", format="%0.2f",
                width=8)
        self.amountSpinbox.config(validatecommand=(
                self.amountSpinbox.register(self.validate), "%P"))
        self.resultLabel = ttk.Label(self) 
Example #11
Source File: Main.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_widgets(self):
        self.sourceLabel = ttk.Label(self, text="Source Folder:",
                underline=-1 if TkUtil.mac() else 1)
        self.sourceEntry = ttk.Entry(self, width=30,
                textvariable=self.sourceText)
        self.sourceButton = TkUtil.Button(self, text="Source...",
                underline=0, command=lambda *args:
                    self.choose_folder(SOURCE))
        self.helpButton = TkUtil.Button(self, text="Help", underline=0,
                command=self.help)
        self.targetLabel = ttk.Label(self, text="Target Folder:",
                underline=-1 if TkUtil.mac() else 1)
        self.targetEntry = ttk.Entry(self, width=30,
                textvariable=self.targetText)
        self.targetButton = TkUtil.Button(self, text="Target...",
                underline=0, command=lambda *args:
                    self.choose_folder(TARGET))
        self.aboutButton = TkUtil.Button(self, text="About", underline=1,
                command=self.about)
        self.statusLabel = ttk.Label(self, textvariable=self.statusText)
        self.scaleButton = TkUtil.Button(self, text="Scale",
                underline=1, command=self.scale_or_cancel,
                default=tk.ACTIVE, state=tk.DISABLED)
        self.quitButton = TkUtil.Button(self, text="Quit", underline=0,
                command=self.close)
        self.dimensionLabel = ttk.Label(self, text="Max. Dimension:",
                underline=-1 if TkUtil.mac() else 6)
        self.dimensionCombobox = ttk.Combobox(self,
                textvariable=self.dimensionText, state="readonly",
                values=("50", "100", "150", "200", "250", "300", "350",
                        "400", "450", "500"))
        TkUtil.set_combobox_item(self.dimensionCombobox, "400") 
Example #12
Source File: Display.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_widgets(self):
        self.wordWrapLabel = ttk.Label(self, text="Wrap:")
        self.wordWrapCombobox = ttk.Combobox(self, state="readonly",
                values=["None", "Character", "Word"],
                textvariable=self.__wordWrap, width=10)
        self.blockCursorCheckbutton = ttk.Checkbutton(self,
                text="Block Cursor", variable=self.__blockCursor)
        self.lineSpacingLabel = ttk.Label(self, text="Line Spacing:")
        self.lineSpacingSpinbox = tk.Spinbox(self, from_=0, to=32,
                width=3, validate="all", justify=tk.RIGHT,
                textvariable=self.__lineSpacing)
        self.lineSpacingSpinbox.config(validatecommand=(
                self.lineSpacingSpinbox.register(self.__validate_int),
                    "lineSpacingSpinbox", "%P")) 
Example #13
Source File: Main.py    From python-in-practice with GNU General Public License v3.0 5 votes vote down vote up
def create_toolbar(self):
        self.toolbar = ttk.Frame(self.master)
        newButton = ttk.Button(self.toolbar, text=NEW, takefocus=False,
                image=self.images[NEW], command=self.board.new_game)
        TkUtil.Tooltip.Tooltip(newButton, text="New Game")
        zoomLabel = ttk.Label(self.toolbar, text="Zoom:")
        self.zoomSpinbox = Spinbox(self.toolbar,
                textvariable=self.zoom, from_=Board.MIN_ZOOM,
                to=Board.MAX_ZOOM, increment=Board.ZOOM_INC, width=3,
                justify=tk.RIGHT, validate="all")
        self.zoomSpinbox.config(validatecommand=(
                self.zoomSpinbox.register(self.validate_int), "%P"))
        TkUtil.Tooltip.Tooltip(self.zoomSpinbox, text="Zoom level (%)")
        self.shapeCombobox = ttk.Combobox(self.toolbar, width=8,
                textvariable=self.shapeName, state="readonly",
                values=sorted(Shapes.ShapeForName.keys()))
        TkUtil.Tooltip.Tooltip(self.shapeCombobox, text="Tile Shape")
        TkUtil.add_toolbar_buttons(self.toolbar, (newButton, None,
                zoomLabel, self.zoomSpinbox, self.shapeCombobox))
        self.toolbar.pack(side=tk.TOP, fill=tk.X, before=self.board) 
Example #14
Source File: frame_objects.py    From crappy with GNU General Public License v2.0 5 votes vote down vote up
def add_combobox(self, **kwargs):
    """
    To add a combobox. Will automatically add an attribute.
    Args:
    - entries: a list that contains every selectable option.
    - variable: the name of the variable, that will become an attribute.
    - default_index: to define which default entry to show on the combobox.
    - var
    """
    widgets_dict = kwargs.pop("widgets_dict", None)
    frame = kwargs.pop("frame", None)
    entries = kwargs.pop("entries", None)
    name = kwargs.pop("name", "combobox")
    variable_name = kwargs.pop("variable", name + "_var")
    default_index = kwargs.pop("default", 0)

    var = tk.StringVar()
    var.set(entries[default_index])

    setattr(self, variable_name, var)

    combo_box = ttk.Combobox(frame,
                             textvariable=var,
                             values=entries,
                             state='readonly')

    widgets_dict[name] = combo_box 
Example #15
Source File: SikuliGui.py    From lackey with MIT License 5 votes vote down vote up
def __init__(self, parent, msg, title, options, default, text_variable):
        tk.Frame.__init__(self, parent)
        self.parent = parent
        self.parent.protocol("WM_DELETE_WINDOW", self.cancel_function)
        self.parent.bind('<Return>', self.ok_function)
        self.parent.title(title)
        self.input_text = text_variable
        self.input_text.set(default)
        if Settings.PopupLocation:
            self.parent.geometry("+{}+{}".format(
                Settings.PopupLocation.x,
                Settings.PopupLocation.y))
        self.msg = tk.Message(self.parent, text=msg)
        self.msg.grid(row=0, sticky="NSEW", padx=10, pady=10)
        self.input_list = ttk.Combobox(
            self.parent,
            textvariable=self.input_text,
            state="readonly",
            values=options)
        #self.input_list.activate(options.index(default))
        self.input_list.grid(row=1, sticky="EW", padx=10)
        self.button_frame = tk.Frame(self.parent)
        self.button_frame.grid(row=2, sticky="E")
        self.cancel = tk.Button(
            self.button_frame,
            text="Cancel",
            command=self.cancel_function,
            width=10)
        self.cancel.grid(row=0, column=0, padx=10, pady=10)
        self.ok_button = tk.Button(
            self.button_frame,
            text="Ok",
            command=self.ok_function,
            width=10)
        self.ok_button.grid(row=0, column=1, padx=10, pady=10)
        self.input_list.focus_set() 
Example #16
Source File: EditableTreeview.py    From PyEngine3D with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def inplace_combobox(self, col, item, values, readonly=True):
        state = 'readonly' if readonly else 'normal'
        if col not in self._inplace_vars:
            self._inplace_vars[col] = tk.StringVar()
        svar = self._inplace_vars[col]
        svar.set(self.__get_value(col, item))
        if col not in self._inplace_widgets:
            self._inplace_widgets[col] = ttk.Combobox(self,
                                                      textvariable=svar, values=values, state=state)
        cb = self._inplace_widgets[col]
        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))
        self._inplace_widgets_show[col] = True 
Example #17
Source File: GUI.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
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 #18
Source File: GUI_MySQL.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
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 #19
Source File: GUI_Not_OOP.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
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 #20
Source File: GUI_OOP.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
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 #21
Source File: autocompletecombobox.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def autocomplete(self, delta=0):
        """
        Autocomplete the Combobox.

        :param delta: 0, 1 or -1: how to cycle through possible hits
        :type delta: int
        """
        if delta:  # need to delete selection otherwise we would fix the current position
            self.delete(self.position, tk.END)
        else:  # set position to end so selection starts where textentry ended
            self.position = len(self.get())
        # collect hits
        _hits = []
        for element in self._completion_list:
            if element.lower().startswith(self.get().lower()):  # Match case insensitively
                _hits.append(element)
        # if we have a new hit list, keep this in mind
        if _hits != self._hits:
            self._hit_index = 0
            self._hits = _hits
        # only allow cycling if we are in a known hit list
        if _hits == self._hits and self._hits:
            self._hit_index = (self._hit_index + delta) % len(self._hits)
        # now finally perform the auto completion
        if self._hits:
            self.delete(0, tk.END)
            self.insert(0, self._hits[self._hit_index])
            self.select_range(self.position, tk.END) 
Example #22
Source File: autocompletecombobox.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def configure(self, **kwargs):
        """Configure widget specific keyword arguments in addition to :class:`ttk.Combobox` keyword arguments."""
        if "completevalues" in kwargs:
            self.set_completion_list(kwargs.pop("completevalues"))
        return ttk.Combobox.configure(self, **kwargs) 
Example #23
Source File: autocompletecombobox.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def cget(self, key):
        """Return value for widget specific keyword arguments"""
        if key == "completevalues":
            return self._completion_list
        return ttk.Combobox.cget(self, key) 
Example #24
Source File: autocompletecombobox.py    From ttkwidgets with GNU General Public License v3.0 5 votes vote down vote up
def keys(self):
        """Return a list of all resource names of this widget."""
        keys = ttk.Combobox.keys(self)
        keys.append("completevalues")
        return keys 
Example #25
Source File: progress_tab.py    From hwk-mirror with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, **kwargs):
        self.removed = True
        self._ticket = None
        self.category = None
        self.item_selector = ttk.Combobox(parent,
                state="readonly",
                style="ItemEditor.TCombobox",
                font=self.font,
                width=type(self).longest_item,
                postcommand=self.post_command)
        
        self.edit_options = LabelButton(parent, "Options",
                width=7,
                font=self.font,
                command=self._options_callback(parent))
        
        self.remove_item = LabelButton(parent, "Remove",
                width=7,
                font=self.font,
                bg="red",
                command=self._remove_callback)

        self.add_item = LabelButton(parent, "",
                width=7,
                font=self.font,
                command=self._add_callback) 
Example #26
Source File: server_widgets.py    From hwk-mirror with GNU General Public License v3.0 5 votes vote down vote up
def __new__(cls, parent, font=("Courier", 18)):

        lc = localtime()
        year = int(lc[0]) - 5
        year = [str(year + i) for i in range(10)]
        month = [str(1 + i) for i in range(12)]
        hour = [str(1 + i) for i in range(12)]
    
        year = ttk.Combobox(parent, values=year, width=5, font=font)
        year.set(lc[0])

        month = ttk.Combobox(parent, values=month, width=3, font=font)
        month.set(lc[1])

        day_var = tk.StringVar(parent)
        day_var.set(lc[2])
        day = tk.Entry(parent, textvariable=day_var, width=3, font=font)
        object.__setattr__(day, "set", day_var.set)
        object.__setattr__(day, "get", day_var.get)
        
        
        hour = ttk.Combobox(parent, values=hour, width=3, font=font)
        hour.set(strftime("%I", lc))
        
        minute_var = tk.StringVar(parent)
        minute_var.set(lc[4])
        minute = tk.Entry(parent, textvariable=minute_var, width=2, font=font)
        object.__setattr__(minute, "set", minute_var.set)
        object.__setattr__(minute, "get", minute_var.get)
    

        ampm = ttk.Combobox(parent, values=["AM", "PM"], width=3, font=font)
        ampm.set("AM")

        return super().__new__(cls, (month, day, year, hour, minute, ampm)) 
Example #27
Source File: options_frame_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def change_categorical_box(self):
        ''' Updates categories that can be chosen as categorical category
            when the user clicks on the Combobox.
        '''
        values = [category for category in self.current_categories if
                  category and category not in
                  self.input_categories_frame.category_objects.keys() and
                  category not in
                  self.output_categories_frame.category_objects.keys()]
        values.append('')
        self.categorical_box.config(values=values) 
Example #28
Source File: options_frame_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def on_categorical_box_change(self, *args):
        ''' Updates value of the CATEGORICAL_CATEGORY in parameters.
            This method is called when the user clicks on the Combobox and
            chooses one item from the drop-down list.

            Args:
                *args: are provided by the StringVar trace method and are
                    ignored in this method.
        '''
        categorical_var = self.combobox_text_var.get()
        self.params.update_parameter('CATEGORICAL_CATEGORY', categorical_var) 
Example #29
Source File: options_frame_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def set_categorical_box(self, categorical_param):
        ''' Sets the value of Combobox with categorical category according
            to a given value
            if this value is in the list of values of this Combobox.
            If the given value
            is not in the list of values, a warning is displayed.

            Args:
                categorical_param (str): value of the categorical category.
        '''
        if categorical_param in self.categorical_box.cget('values'):
            self.combobox_text_var.set(categorical_param)
        else:
            self._show_warning_combobox(categorical_param) 
Example #30
Source File: load_xls_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def ok(self, event=None):
        ''' This method is called if the user presses OK button.
            In this case sheet name is set to the currently selected value
            in Combobox.

            Args:
                event (Tk event, optional): event that is given when the
                    button is pressed.  It is ignored in this method.
        '''
        self.parent.destroy()