本文整理汇总了Python中ttk.Button方法的典型用法代码示例。如果您正苦于以下问题:Python ttk.Button方法的具体用法?Python ttk.Button怎么用?Python ttk.Button使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk
的用法示例。
在下文中一共展示了ttk.Button方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_pipeline
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def load_pipeline(self, event=None):
top = tkinter.Toplevel()
master_selector = SemTkMasterSelector(top, os.path.join(sem.SEM_DATA_DIR, "resources"))
lang_selector = SemTkLangSelector(top, os.path.join(sem.SEM_DATA_DIR, "resources"))
lang_selector.master_selector = master_selector
vars_cur_row = 0
vars_cur_row, _ = lang_selector.grid(row=vars_cur_row, column=0)
vars_cur_row, _ = master_selector.grid(row=vars_cur_row, column=0)
def cancel(event=None):
if self.pipeline is not None:
self.tag_document_btn.configure(state=tkinter.NORMAL)
top.destroy()
def ok(event=None):
path = master_selector.workflow()
pipeline, _, _, _ = sem.modules.tagger.load_master(path)
self.pipeline = pipeline
cancel()
ok_btn = ttk.Button(top, text="load workflow", command=ok)
ok_btn.grid(row=vars_cur_row, column=0)
cancel_btn = ttk.Button(top, text="cancel", command=cancel)
cancel_btn.grid(row=vars_cur_row, column=1)
示例2: toggle_empty_state
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def toggle_empty_state(self, show, addRow=True):
if (show):
self.root.minsize(width=0, height=260)
self.root.maxsize(width=1200, height=260)
self.emptyStateButton = ttk.Button(self.mainPluginFrame, text="Add Plugin Options", command=lambda: self.toggle_empty_state(False))
self.emptyStateButton.grid(column=0, row=0, sticky=(N,W,E,S))
if self.showingHeader:
self.headerLabel.destroy()
self.addButton.destroy()
self.generateButton.destroy()
else:
self.root.minsize(width=0, height=380)
self.root.maxsize(width=1200, height=380)
self.showingHeader = True
self.headerLabel = ttk.Label(self.mainPluginFrame, text="Plugin Options")
self.headerLabel.grid(column=0, row=0, sticky=(N,W), pady=(0, 15))
self.addButton = ttk.Button(self.mainPluginFrame, text='Add Plugin Option', command=self.add_plugin_option)
self.addButton.grid(column=1, row=0, sticky=(N,E))
self.generateButton = ttk.Button(self.mainPluginFrame, text='Generate Header', command=self.generate_plugin_options_header)
self.generateButton.grid(column=2, row=0, sticky=(N,E))
if self.emptyStateButton:
if addRow:
self.add_plugin_option()
self.emptyStateButton.destroy()
示例3: initialize
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def initialize(self):
"""
Set window layout.
"""
self.grid()
self.respond = ttk.Button(self, text='Get Response', command=self.get_response)
self.respond.grid(column=0, row=0, sticky='nesw', padx=3, pady=3)
self.usr_input = ttk.Entry(self, state='normal')
self.usr_input.grid(column=1, row=0, sticky='nesw', padx=3, pady=3)
self.conversation_lbl = ttk.Label(self, anchor=tk.E, text='Conversation:')
self.conversation_lbl.grid(column=0, row=1, sticky='nesw', padx=3, pady=3)
self.conversation = ScrolledText.ScrolledText(self, state='disabled')
self.conversation.grid(column=0, row=2, columnspan=2, sticky='nesw', padx=3, pady=3)
示例4: example1
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def example1():
def print_sel():
print(cal.selection_get())
cal.see(datetime.date(year=2016, month=2, day=5))
top = tk.Toplevel(root)
import datetime
today = datetime.date.today()
mindate = datetime.date(year=2018, month=1, day=21)
maxdate = today + datetime.timedelta(days=5)
print(mindate, maxdate)
cal = Calendar(top, font="Arial 14", selectmode='day', locale='en_US',
mindate=mindate, maxdate=maxdate, disabledforeground='red',
cursor="hand1", year=2018, month=2, day=5)
cal.pack(fill="both", expand=True)
ttk.Button(top, text="ok", command=print_sel).pack()
示例5: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def __init__(self, master=None, **kw):
if platform == 'darwin':
kw['highlightbackground'] = kw.pop('highlightbackground', PAGEBG)
tk.Button.__init__(self, master, **kw)
elif platform == 'win32':
ttk.Button.__init__(self, master, style='nb.TButton', **kw)
else:
ttk.Button.__init__(self, master, **kw)
示例6: setUp
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def setUp(self):
support.root_deiconify()
self.widget = ttk.Button(width=0, text="Text")
self.widget.pack()
self.widget.wait_visibility()
示例7: test_invoke
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def test_invoke(self):
success = []
btn = ttk.Button(command=lambda: success.append(1))
btn.invoke()
self.assertTrue(success)
示例8: setUp
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def setUp(self):
super(WidgetTest, self).setUp()
self.widget = ttk.Button(self.root, width=0, text="Text")
self.widget.pack()
self.widget.wait_visibility()
示例9: create
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def create(self, **kwargs):
return ttk.Button(self.root, **kwargs)
示例10: test_invoke
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def test_invoke(self):
success = []
btn = ttk.Button(self.root, command=lambda: success.append(1))
btn.invoke()
self.assertTrue(success)
示例11: create_bool_plugin_option_row
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def create_bool_plugin_option_row(self, pluginOptionType, pluginOptionFrame, pluginOptionTypeVar, row=-1, defaultVal=1):
if not self.plugin_option_is_type_bool(pluginOptionType):
return
ttk.Label(pluginOptionFrame, text=' ').grid(column=1, row=row)
ttk.Label(pluginOptionFrame, text=' ').grid(column=2, row=row)
ttk.Label(pluginOptionFrame, text=' ').grid(column=3, row=row)
ttk.Label(pluginOptionFrame, text=' ').grid(column=4, row=row)
ttk.Label(pluginOptionFrame, text=' ').grid(column=5, row=row)
ttk.Label(pluginOptionFrame, text='Default Value:').grid(column=6, row=row, sticky=(E))
pluginOptionDefaultValue = StringVar()
pluginOptionDefaultValue.set(self.boolOptions[defaultVal])
optionmenu = OptionMenu(pluginOptionFrame, pluginOptionDefaultValue, *self.boolOptions)
optionmenu.grid(column=7, row=row, sticky=(W))
# Known issue with MacOS TCL where the background color of ttk is not defined and different from the Tkinter background color
operating_sys = sys.platform
if operating_sys == "darwin":
optionmenu.configure(background="#E4E4E4")
pluginOptionRow = {
"rowFrame": pluginOptionFrame,
"optionTypeVar": pluginOptionTypeVar,
"optionDefaultVar": pluginOptionDefaultValue
}
ttk.Button(pluginOptionFrame, text='Remove', command=lambda: self.remove_plugin_option(pluginOptionRow)).grid(column=8, row=row, sticky=(E))
return pluginOptionRow
示例12: show_window
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def show_window(self):
self.mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
self.mainframe.columnconfigure(0, weight=1)
self.mainframe.rowconfigure(0, weight=1)
ttk.Label(self.mainframe, text=" ").grid(column=0, row=0, sticky=(N,W))
ttk.Label(self.mainframe, text='1. Pair your Light Panels ').grid(column=1, row=1, sticky=(N, W))
ttk.Checkbutton(self.mainframe, variable=self.should_use_simulator, text='Use Light Panels Simulator', command=self.toggle_aurora_simulator).grid(column=2, row=1, sticky=(N,W))
ttk.Label(self.mainframe, text='IP Address').grid(column=1, row=2, sticky=(N, W))
self.pair_entry = ttk.Entry(self.mainframe, width=35, textvariable=self.ip_addr)
self.pair_entry.grid(column=2, row=2, columnspan=2, sticky=(N, W))
self.pair_button = ttk.Button(self.mainframe, width=12, text='Pair', command=self.authenticate_with_aurora)
self.pair_button.grid(column=4, row=2, sticky=(N,W))
ttk.Label(self.mainframe, text='2. Make a color palette').grid(column=1, row=3, sticky=(N, W))
ttk.Button(self.mainframe, text="Add Color", command=self.add_color_to_palette).grid(column=1, row=4, sticky=(N, W))
ttk.Label(self.mainframe, textvariable=self.curr_palette_string, wraplength=500).grid(column=2, row=4, columnspan=2, sticky=(N, W))
ttk.Button(self.mainframe, width=12, text="Clear palette", command=self.clear_palette).grid(column=4, row=4, sticky=(N, W))
ttk.Label(self.mainframe, text='3. Build your plugin').grid(column=1, row=5, sticky=(N, W))
ttk.Label(self.mainframe, text='Plugin Location').grid(column=1, row=6, sticky=(N, W))
ttk.Entry(self.mainframe, width=35, textvariable=self.plugin_dir_path).grid(column=2, row=6, columnspan=2, sticky=(N, W))
ttk.Button(self.mainframe, width=12, text='Browse', command=self.get_plugin_dir).grid(column=4, row=6, sticky=(N, W))
ttk.Button(self.mainframe, text='Build', command=self.build_plugin).grid(column=2, row=7, columnspan=1, sticky=(N,E))
ttk.Button(self.mainframe, text='Upload & Run', command=self.play_plugin).grid(column=3, row=7, columnspan=1, sticky=N)
ttk.Button(self.mainframe, width=12, text='Stop Plugin', command=self.stop_plugin).grid(column=4, row=7, columnspan=1, sticky=(N, W))
ttk.Label(self.mainframe, text=" ").grid(column=5, row=8, sticky=(N,W))
ttk.Label(self.mainframe, text=" ").grid(column=5, row=9, sticky=(N,W))
self.pluginOptionsGUI.create_plugin_frame()
self.root.mainloop()
示例13: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def __init__(self, top=None):
"""This class configures and populates the toplevel window.
top is the toplevel containing window."""
_bgcolor = '#d9d9d9' # X11 color: 'gray85'
_fgcolor = '#000000' # X11 color: 'black'
_compcolor = '#d9d9d9' # X11 color: 'gray85'
_ana1color = '#d9d9d9' # X11 color: 'gray85'
self.style = ttk.Style()
if sys.platform == "win32":
self.style.theme_use('winnative')
self.style.configure('.', background=_bgcolor)
self.style.configure('.', foreground=_fgcolor)
self.style.configure('.', font="TkDefaultFont")
self.style.map('.', background=[('selected', _compcolor), ('active', _ana1color)])
top.geometry("388x169+474+249")
top.title("Cheetah Update")
top.configure(background="#d9d9d9")
top.configure(highlightbackground="#d9d9d9")
top.configure(highlightcolor="black")
self.TButton1 = ttk.Button(top)
self.TButton1.place(relx=0.23, rely=0.71, height=27, width=87)
self.TButton1.configure(command=cheetah_update_support.check_updates)
self.TButton1.configure(takefocus="")
self.TButton1.configure(textvariable=cheetah_update_support.check_update)
self.Message1 = Message(top)
self.Message1.place(relx=0.05, rely=0.12, relheight=0.44, relwidth=0.87)
self.Message1.configure(background="#d9d9d9")
self.Message1.configure(foreground="#000000")
self.Message1.configure(highlightbackground="#d9d9d9")
self.Message1.configure(highlightcolor="black")
self.Message1.configure(textvariable=cheetah_update_support.update_msg)
self.Message1.configure(width=337)
self.TButton2 = ttk.Button(top)
self.TButton2.place(relx=0.57, rely=0.71, height=27, width=87)
self.TButton2.configure(command=cheetah_update_support.exit_update)
self.TButton2.configure(takefocus="")
self.TButton2.configure(text='''Cancel''')
示例14: footer
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def footer(self):
# Run button
run_button = ttk.Button(self.master, text = "Run", command = self.run)
# Exit button
exit_button = ttk.Button(self.master, text = "Exit", command = self.close_window)
# Layout
run_button.place(relwidth = 0.1, relx = 0.9, rely = 1, x = -5, y = -5, anchor = "se")
exit_button.place(relwidth = 0.1, relx = 1, rely = 1, x = -5, y = -5, anchor = "se")
示例15: body
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Button [as 别名]
def body(self, master, row, columns=DEFAULT_COLUMNS, **kwargs):
"""
Place the required elements using the grid layout method.
Returns the number of rows taken by this element.
"""
label = ttk.Label(master, text=self.text)
label.grid(row=row, column=0, columnspan=1, sticky="e")
self.entry = ttk.Entry(master, textvariable=self.value)
self.entry.grid(row=row, column=1, columnspan=columns - 1, sticky="ew")
if self.directory:
self.choose = ttk.Button(
master,
text="Choose...",
command=lambda: self.value.set(tkFileDialog.askdirectory()),
)
else:
self.choose = ttk.Button(
master,
text="Choose...",
command=lambda: self.value.set(tkFileDialog.askopenfilename()),
)
self.choose.grid(row=row + 1, column=1, sticky="w")
if self.optional:
self.clear = ttk.Button(
master, text="Clear", command=lambda: self.value.set("")
)
self.clear.grid(row=row + 1, column=2, sticky="e")
return 2