Python tkinter.Spinbox() Examples

The following are 30 code examples of tkinter.Spinbox(). 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: navigation_frame_gui.py    From pyDEA with MIT License 7 votes vote down vote up
def create_widgets(self):
        ''' Creates all necessary widgets for navigation.
        '''
        prev_btn = Button(self, text='<<', width=5,
                          command=self.show_prev_page)
        prev_btn.grid(row=0, column=0, sticky=N, padx=3)
        next_btn = Button(self, text='>>', width=5,
                          command=self.show_next_page)
        next_btn.grid(row=0, column=1, sticky=N)
        goto_lbl = Label(self, text='Go to')
        goto_lbl.grid(row=0, column=3, sticky=N, padx=5)

        self.goto_spin = Spinbox(self, width=7, from_=1, to=1,
                                 textvariable=self.current_page_str,
                                 command=self.on_page_change)

        self.goto_spin.bind('<Return>', self.on_page_change)
        self.goto_spin.grid(row=0, column=4, sticky=N, padx=5)
        nb_pages_lb = Label(self, textvariable=self.text_var_nb_pages)
        nb_pages_lb.grid(row=0, column=5, sticky=W+N, padx=5)
        self.reset_navigation() 
Example #2
Source File: labelSettingsFrame.py    From PyEveLiveDPS with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, parent=None, title="", decimalPlaces=0, inThousands=0, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)
        gridFrame = self._nametowidget(parent.winfo_parent())
        self.parent = self._nametowidget(gridFrame.winfo_parent())
        
        self.grid(row="0", column="0", sticky="ew")
        self.columnconfigure(0,weight=1)
        self.singleLabel = singleLabel = tk.Label(self, text=title)
        singleLabel.grid(row="0",column="0", sticky="ew")
        self.listbox = listbox = tk.Spinbox(self, from_=0, to=9, width=1, borderwidth=1, highlightthickness=0)
        listbox.delete(0,tk.END)
        listbox.insert(0,decimalPlaces)
        listbox.grid(row="0", column="1")
        checkboxValue = tk.IntVar()
        checkboxValue.set(inThousands)
        self.checkbox = checkbox = tk.Checkbutton(self, text="K", variable=checkboxValue, borderwidth=0, highlightthickness=0)
        checkbox.var = checkboxValue
        checkbox.grid(row="0", column="2")
        singleLabel.bind("<Button-1>", lambda e:self.dragStart(e, listbox, checkbox)) 
Example #3
Source File: gui_widgets.py    From SVPV with MIT License 6 votes vote down vote up
def __init__(self, parent):
        tk.LabelFrame.__init__(self, parent)
        self.title = tk.Label(self, text='SV Length')

        self.len_GT_On = tk.IntVar(value=0)
        self.len_GT_On_CB = tk.Checkbutton(self, text=">", justify=tk.LEFT, variable=self.len_GT_On)
        self.len_GT_val = tk.Spinbox(self, values=(1,5,10,50,100,500), width=3)
        self.len_GT_Units = tk.Spinbox(self, values=("bp", "kbp", "Mbp"), width=3)

        self.len_LT_On = tk.IntVar(value=0)
        self.len_LT_On_CB = tk.Checkbutton(self, text="<", justify=tk.LEFT, variable=self.len_LT_On)
        self.len_LT_val = tk.Spinbox(self, values=(1,5,10,50,100,500), width=3)
        self.len_LT_Units = tk.Spinbox(self, values=("bp", "kbp", "Mbp"), width=3)

        self.title.grid(row=0, column=0, sticky=tk.EW, columnspan=4)
        self.len_GT_On_CB.grid(row=1, column=0, sticky=tk.EW)
        self.len_GT_val.grid(row=2, column=0, sticky=tk.EW)
        self.len_GT_Units.grid(row=2, column=1, sticky=tk.EW)
        self.len_LT_On_CB.grid(row=1, column=2, sticky=tk.EW)
        self.len_LT_val.grid(row=2, column=2, sticky=tk.EW)
        self.len_LT_Units.grid(row=2, column=3, sticky=tk.EW) 
Example #4
Source File: case.py    From mentalist with MIT License 6 votes vote down vote up
def open_case_popup(self, case):
        '''Open popup for defining the Nth character to toggle
        '''
        self.case_popup = Tk.Toplevel()
        self.case_popup.withdraw()
        self.case_popup.title('{}: Nth Character'.format(case))
        self.case_popup.resizable(width=False, height=False)
        frame = Tk.Frame(self.case_popup)
        lb = Tk.Label(frame, text='Select Number of Nth Character'.format(self.title))
        lb.pack(fill='both', side='top')

        sp_box = Tk.Frame(frame)
        lb1 = Tk.Label(sp_box, text='Number: ')
        lb1.pack(side='left', padx=5)
        self.sp_case = Tk.Spinbox(sp_box, width=12, from_=1, to=10000)
        self.sp_case.pack(side='left')
        sp_box.pack(fill='both', side='top', padx=30, pady=20)

        # Ok and Cancel buttons
        btn_box = Tk.Frame(frame)
        btn_cancel = Tk.Button(btn_box, text='Cancel', command=self.cancel_case_popup)
        btn_cancel.pack(side='right', padx=10, pady=20)
        btn_ok = Tk.Button(btn_box, text='Ok', command=partial(self.on_ok_case_popup, case))
        btn_ok.pack(side='left', padx=10, pady=20)
        btn_box.pack()
        frame.pack(fill='both', padx=10, pady=10)
        
        center_window(self.case_popup, self.main.master)
        self.case_popup.focus_set() 
Example #5
Source File: table_modifier_gui.py    From pyDEA with MIT License 6 votes vote down vote up
def add_rows(self):
        ''' Adds rows to the data table. Number of rows is specified in Spinbox.
            If invalid value is given in Spinbox, only one row is added.
            Rows are added to the end of the table.
        '''
        nb_rows = self.get_nb_to_add(self.row_str_var)
        for i in range(nb_rows):
            self.table.add_row()

        # if data is displayed on multiple pages, when adding new row
        # we re-display data
        if len(self.table.cells) > 1:
            start_row = self.table.cells[1][0].data_row
            if start_row != -1:
                if len(self.table.data) - start_row >= self.table.nb_rows - 1:
                    # we need to reposition data on several pages
                    self.table.display_data(start_row)
                    nb_pages = calculate_nb_pages(len(self.table.data),
                                                  self.table.nb_rows)
                    self.set_navigation(nb_pages, False) 
Example #6
Source File: GUI_MySQL.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 5 votes vote down vote up
def _combo(self, val=0):
        value = self.combo.get()
        self.scr.insert(tk.INSERT, value + '\n')
    
    # Spinbox callback 
Example #7
Source File: GUI_Complexity_start_add_button.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def clearScrol(self):
        self.scr.delete('1.0', tk.END)    
    
    # Spinbox callback 
Example #8
Source File: GUI_Complexity_start_add_three_more_buttons_add_more.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def clearScrol(self):
        self.scr.delete('1.0', tk.END)    
    
    # Spinbox callback 
Example #9
Source File: 6.08.py    From Tkinter-GUI-Application-Development-Blueprints-Second-Edition with MIT License 5 votes vote down vote up
def draw_text_options(self):
        tk.Label(self.top_bar, text='Text:').pack(side="left")
        self.text_entry_widget = tk.Entry(self.top_bar, width=20)
        self.text_entry_widget.pack(side="left")
        tk.Label(self.top_bar, text='Font size:').pack(side="left")
        self.font_size_spinbox = tk.Spinbox(
            self.top_bar, from_=14, to=100, width=3)
        self.font_size_spinbox.pack(side="left")
        self.create_fill_options_combobox()
        self.create_text_button = tk.Button(
            self.top_bar, text="Go", command=self.on_create_text_button_clicked)
        self.create_text_button.pack(side="left", padx=5) 
Example #10
Source File: GUI_const_42_print.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #11
Source File: GUI_const_42_777.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #12
Source File: GUI_spinbox_two_sunken.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #13
Source File: GUI.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 5 votes vote down vote up
def _combo(self, val=0):
        value = self.combo.get()
        self.scr.insert(tk.INSERT, value + '\n')
    
    # Spinbox callback 
Example #14
Source File: ULDO01.py    From mcculw with MIT License 5 votes vote down vote up
def create_widgets(self):
        '''Create the tkinter UI'''
        if self.port != None:
            main_frame = tk.Frame(self)
            main_frame.pack(fill=tk.X, anchor=tk.NW)

            positive_int_vcmd = self.register(self.validate_positive_int_entry)

            curr_row = 0
            value_label = tk.Label(main_frame)
            value_label["text"] = "Value:"
            value_label.grid(row=curr_row, column=0, sticky=tk.W)

            self.data_value_variable = StringVar()
            self.data_value_entry = tk.Spinbox(
                main_frame, from_=0, to=255, textvariable=self.data_value_variable,
                validate="key", validatecommand=(positive_int_vcmd, "%P"))
            self.data_value_entry.grid(row=curr_row, column=1, sticky=tk.W)
            self.data_value_variable.trace("w", self.data_value_changed)

            button_frame = tk.Frame(self)
            button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

            quit_button = tk.Button(button_frame)
            quit_button["text"] = "Quit"
            quit_button["command"] = self.exit
            quit_button.grid(row=0, column=1, padx=3, pady=3)
        else:
            self.create_unsupported_widgets(self.board_num) 
Example #15
Source File: ULGT01.py    From mcculw with MIT License 5 votes vote down vote up
def create_widgets(self):
        '''Create the tkinter UI'''
        main_frame = tk.Frame(self)
        main_frame.pack(fill=tk.X, anchor=tk.NW)

        positive_int_vcmd = self.register(self.validate_positive_int_entry)

        err_code_label = tk.Label(main_frame)
        err_code_label["text"] = "Error Code:"
        err_code_label.grid(row=0, column=0, sticky=tk.W)

        self.err_code_variable = StringVar(0)
        self.err_code_entry = tk.Spinbox(
            main_frame, from_=0, to=2000,
            textvariable=self.err_code_variable,
            validate="key", validatecommand=(positive_int_vcmd, "%P"))
        self.err_code_entry.grid(row=0, column=1, sticky=tk.W)
        self.err_code_variable.trace("w", self.err_code_changed)

        err_msg_left_label = tk.Label(main_frame)
        err_msg_left_label["text"] = "Message:"
        err_msg_left_label.grid(row=1, column=0, sticky=tk.NW)

        self.err_msg_label = tk.Label(
            main_frame, justify=tk.LEFT, wraplength=300)
        self.err_msg_label["text"] = "No error has occurred."
        self.err_msg_label.grid(row=1, column=1, sticky=tk.W)

        button_frame = tk.Frame(self)
        button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

        quit_button = tk.Button(button_frame)
        quit_button["text"] = "Quit"
        quit_button["command"] = self.master.destroy
        quit_button.grid(row=0, column=0, padx=3, pady=3)


# Start the example if this module is being run 
Example #16
Source File: ULGT03.py    From mcculw with MIT License 5 votes vote down vote up
def create_widgets(self):
        '''Create the tkinter UI'''
        main_frame = tk.Frame(self)
        main_frame.pack(fill=tk.X, anchor=tk.NW)

        positive_int_vcmd = self.register(self.validate_positive_int_entry)

        board_num_label = tk.Label(main_frame)
        board_num_label["text"] = "Board Number:"
        board_num_label.grid(row=0, column=0, sticky=tk.W)

        self.board_num_variable = StringVar()
        board_num_entry = tk.Spinbox(
            main_frame, from_=0, to=self.max_board_num,
            textvariable=self.board_num_variable,
            validate="key", validatecommand=(positive_int_vcmd, "%P"))
        board_num_entry.grid(row=0, column=1, sticky=tk.W)
        self.board_num_variable.trace("w", self.board_num_changed)

        info_groupbox = tk.LabelFrame(self, text="Board Information")
        info_groupbox.pack(fill=tk.X, anchor=tk.NW, padx=3, pady=3)

        self.info_label = tk.Label(
            info_groupbox, justify=tk.LEFT, wraplength=400)
        self.info_label.grid()

        button_frame = tk.Frame(self)
        button_frame.pack(fill=tk.X, side=tk.RIGHT, anchor=tk.SE)

        quit_button = tk.Button(button_frame)
        quit_button["text"] = "Quit"
        quit_button["command"] = self.master.destroy
        quit_button.grid(row=0, column=0, padx=3, pady=3)


# Start the example if this module is being run 
Example #17
Source File: GUI_Complexity_start.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def clearScrol(self):
        self.scr.delete('1.0', tk.END)    
    
    # Spinbox 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 _combo(self, val=0):
        value = self.combo.get()
        self.scr.insert(tk.INSERT, value + '\n')
    
    # Spinbox callback 
Example #19
Source File: GUI_const_42.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #20
Source File: GUI_progressbar.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #21
Source File: GUI_spinbox_small.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #22
Source File: GUI_tooltip.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #23
Source File: GUI_canvas.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #24
Source File: GUI_spinbox_small_bd_scrol_values.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #25
Source File: GUI_spinbox.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #26
Source File: GUI_spinbox_small_bd.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget 
Example #27
Source File: GUI.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _combo(self, val=0):
        value = self.combo.get()
        self.scr.insert(tk.INSERT, value + '\n')
    
    # Spinbox callback 
Example #28
Source File: fontchooser.py    From Tkinter-GUI-Programming-by-Example with MIT License 5 votes vote down vote up
def __init__(self, master, **kwargs):
        super().__init__(**kwargs)
        self.master = master

        self.transient(self.master)
        self.geometry('500x250')
        self.title('Choose font and size')

        self.configure(bg=self.master.background)

        self.font_list = tk.Listbox(self, exportselection=False)

        self.available_fonts = sorted(families())

        for family in self.available_fonts:
            self.font_list.insert(tk.END, family)

        current_selection_index = self.available_fonts.index(self.master.font_family)
        if current_selection_index:
            self.font_list.select_set(current_selection_index)
            self.font_list.see(current_selection_index)

        self.size_input = tk.Spinbox(self, from_=0, to=99, value=self.master.font_size)

        self.save_button = ttk.Button(self, text="Save", style="editor.TButton", command=self.save)

        self.save_button.pack(side=tk.BOTTOM, fill=tk.X, expand=1, padx=40)
        self.font_list.pack(side=tk.LEFT, fill=tk.Y, expand=1)
        self.size_input.pack(side=tk.BOTTOM, fill=tk.X, expand=1) 
Example #29
Source File: GUI_OOP_class_imported_tooltip.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def click_me(self): 
        self.action.configure(text='Hello ' + self.name.get() + ' ' + 
                         self.number_chosen.get())

    # Spinbox callback 
Example #30
Source File: GUI_const_42_777_global_print.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def _spin():
    value = spin.get()
    print(value)
    scrol.insert(tk.INSERT, value + '\n')
     
# Adding a Spinbox widget