本文整理汇总了Python中tkinter.Spinbox方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.Spinbox方法的具体用法?Python tkinter.Spinbox怎么用?Python tkinter.Spinbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter
的用法示例。
在下文中一共展示了tkinter.Spinbox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
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))
示例2: create_toolbar
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
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)
示例3: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
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)
示例4: create_widgets
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
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()
示例5: add_rows
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
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)
示例6: __init__
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
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)
示例7: open_case_popup
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
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()
示例8: create_widgets
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
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)
示例9: create_widgets
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
def create_widgets(self, master):
self.frame = ttk.Frame(master)
self.columnsLabel = TkUtil.Label(self.frame, text="Columns",
underline=2)
self.columnsSpinbox = Spinbox(self.frame,
textvariable=self.columns, from_=Board.MIN_COLUMNS,
to=Board.MAX_COLUMNS, width=3, justify=tk.RIGHT,
validate="all")
self.columnsSpinbox.config(validatecommand=(
self.columnsSpinbox.register(self.validate_int),
"columnsSpinbox", "%P"))
self.rowsLabel = TkUtil.Label(self.frame, text="Rows",
underline=0)
self.rowsSpinbox = Spinbox(self.frame, textvariable=self.rows,
from_=Board.MIN_ROWS, to=Board.MAX_ROWS, width=3,
justify=tk.RIGHT, validate="all")
self.rowsSpinbox.config(validatecommand=(
self.rowsSpinbox.register(self.validate_int),
"rowsSpinbox", "%P"))
self.maxColorsLabel = TkUtil.Label(self.frame, text="Max. Colors",
underline=0)
self.maxColorsSpinbox = Spinbox(self.frame,
textvariable=self.maxColors, from_=Board.MIN_MAX_COLORS,
to=Board.MAX_MAX_COLORS, width=3, justify=tk.RIGHT,
validate="all")
self.maxColorsSpinbox.config(validatecommand=(
self.maxColorsSpinbox.register(self.validate_int),
"maxColorsSpinbox", "%P"))
示例10: create_widgets
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
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"))
示例11: create_advanced_widgets
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
def create_advanced_widgets(self, master):
self.delayLabel = TkUtil.Label(master, text="Delay (ms)",
underline=0)
self.delaySpinbox = Spinbox(master, textvariable=self.delay,
from_=Board.MIN_DELAY, to=Board.MAX_DELAY, increment=25,
width=4, justify=tk.RIGHT, validate="all")
self.delaySpinbox.config(validatecommand=(
self.delaySpinbox.register(self.validate_int),
"delaySpinbox", "%P"))
self.zoomLabel = TkUtil.Label(master, text="Zoom (%)", underline=0)
self.zoomSpinbox = Spinbox(master,
textvariable=self.options.zoom, from_=Board.MIN_ZOOM,
to=Board.MAX_ZOOM, increment=Board.ZOOM_INC, width=4,
justify=tk.RIGHT, validate="all")
self.zoomSpinbox.config(validatecommand=(
self.zoomSpinbox.register(self.validate_int),
"zoomSpinbox", "%P"))
self.showToolbarCheckbutton = TkUtil.Checkbutton(master,
text="Show Toolbar", underline=5,
variable=self.showToolbar)
self.restoreCheckbutton = TkUtil.Checkbutton(master,
text="Restore Position", underline=0,
variable=self.restore)
示例12: body
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
def body(self, master):
frame = ttk.Frame(master)
label = ttk.Label(frame, text=self.prompt)
label.pack(side=tk.LEFT, fill=tk.X, padx=PAD, pady=PAD)
self.spinbox = Spinbox(frame, from_=self.minimum, to=self.maximum,
textvariable=self.value, validate="all")
self.spinbox.config(validatecommand=(
self.spinbox.register(self.validate), "%P"))
self.spinbox.pack(side=tk.LEFT, padx=PAD, pady=PAD)
return frame, self.spinbox
示例13: inplace_spinbox
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
def inplace_spinbox(self, col, item, min, max, step):
self.clear_inplace_widgets()
self._inplace_item = item
self._inplace_var = tk.StringVar()
svar = self._inplace_var
svar.set(self.__get_value(col, item))
self._inplace_widget = tk.Spinbox(self, textvariable=svar, from_=min, to=max, increment=step)
sb = self._inplace_widget
sb.bind('<Return>', lambda e: self.__update_value(col, item))
sb.bind('<Unmap>', lambda e: self.__update_value(col, item))
sb.bind('<FocusOut>', lambda e: self.__update_value(col, item))
self.__updateWnds(col, item, sb)
示例14: click_me
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
def click_me(self):
self.action.configure(text='Hello ' + self.name.get())
bq.write_to_scrol(self)
sleep(2)
html_data = url.get_html()
print(html_data)
self.scrol.insert(tk.INSERT, html_data)
# Spinbox callback
示例15: click_me
# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Spinbox [as 别名]
def click_me(self):
self.action.configure(text='Hello ' + self.name.get() + ' ' +
self.number_chosen.get())
# Spinbox callback
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:7,代码来源:GUI_multiple_threads.py