本文整理汇总了Python中Tkinter.Button方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.Button方法的具体用法?Python Tkinter.Button怎么用?Python Tkinter.Button使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter
的用法示例。
在下文中一共展示了Tkinter.Button方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: escapePressHandler
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def escapePressHandler(self, event):
"""Handle ESCAPE key events. """
if self.__is_verbose: print "ACTION: ESCAPE key pressed."
# if the camera is previewing -> stop the preview
if self.__camera and self.__preview_is_active:
self.__camera.stop_preview()
self.__preview_is_active = False
if self.__is_verbose: print "INFO: Camera preview stopped. "
# reset focus to application frame
self.focus_set()
# --------------------------------------------------------------------------
# Button Press Events
# --------------------------------------------------------------------------
示例2: __createWidgets
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def __createWidgets(self):
"""Create the widgets. """
if self.__is_verbose: print "INFO: Creating Widgets!"
# create show preview button
self.preview_button = tk.Button(self, text = "Show Camera Feed",
command = self.clickStartPreview)
self.preview_button.grid(row = 1, column = 0,
sticky = tk.W + tk.E + tk.N + tk.S)
# create quit button
self.quit_button = tk.Button(self, text = "Quit",
command = self.clickQuit)
self.quit_button.grid(row = 1, column = 1,
sticky = tk.W + tk.E + tk.N + tk.S)
# --------------------------------------------------------------------------
# Load Image
# --------------------------------------------------------------------------
示例3: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def __init__(self, main_window, msg='Please enter a node:'):
tk.Toplevel.__init__(self)
self.main_window = main_window
self.title('Node Entry')
self.geometry('170x160')
self.rowconfigure(3, weight=1)
tk.Label(self, text=msg).grid(row=0, column=0, columnspan=2,
sticky='NESW',padx=5,pady=5)
self.posibilities = [d['dataG_id'] for n,d in
main_window.canvas.dispG.nodes_iter(data=True)]
self.entry = AutocompleteEntry(self.posibilities, self)
self.entry.bind('<Return>', lambda e: self.destroy(), add='+')
self.entry.grid(row=1, column=0, columnspan=2, sticky='NESW',padx=5,pady=5)
tk.Button(self, text='Ok', command=self.destroy).grid(
row=3, column=0, sticky='ESW',padx=5,pady=5)
tk.Button(self, text='Cancel', command=self.cancel).grid(
row=3, column=1, sticky='ESW',padx=5,pady=5)
# Make modal
self.winfo_toplevel().wait_window(self)
示例4: buttonbox
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def buttonbox(self):
# add standard button box. override if you don't want the
# standard buttons
box = Tkinter.Frame(self)
w = Tkinter.Button(box, text="OK", width=10, command=self.ok, default="active")
w.pack(side="left", padx=5, pady=5)
w = Tkinter.Button(box, text="Cancel", width=10, command=self.cancel)
w.pack(side="left", padx=5, pady=5)
self.bind("<Return>", self.ok)
self.bind("<Escape>", self.cancel)
box.pack()
#
# standard button semantics
示例5: record_result
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def record_result(self, smile=True):
print "Image", self.index + 1, ":", "Happy" if smile is True else "Sad"
self.results[str(self.index)] = smile
# ===================================
# Callback function for the buttons
# ===================================
## smileCallback() : Gets called when "Happy" Button is pressed
## noSmileCallback() : Gets called when "Sad" Button is pressed
## updateImageCount() : Displays the number of images processed
## displayFace() : Gets called internally by either of the button presses
## displayBarGraph(isBarGraph) : computes the bar graph after classification is completed 100%
## _begin() : Resets the Dataset & Starts from the beginning
## _quit() : Quits the Application
## printAndSaveResult() : Save and print the classification result
## loadResult() : Loading the previously stored classification result
## run_once(m) : Decorator to allow functions to run only once
示例6: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def __init__(self, root, main_window, button_opt):
ttk.Frame.__init__(self, root)
self.root = root
self.main_window = main_window
self.current_files = None
self.button_opt = button_opt
# define options for opening or saving a file
self.file_opt = options = {}
options['defaultextension'] = '.txt'
options['filetypes'] = [('all files', '.*'), ('text files', '.txt')]
options['initialdir'] = os.path.expanduser("~")
options['parent'] = root
options['title'] = 'Select files to annotate.'
self.file_selector_button = ttk.Button(self.root, text=u"select file(s)", command=self.filenames)
self.label = ttk.Label(self.root, text=u"selected file(s):")
self.fa_search = tkinter.PhotoImage(file=os.path.join(self.main_window.resource_dir, "images", "fa_search_24_24.gif"))
self.file_selector_button.config(image=self.fa_search, compound=tkinter.LEFT)
self.scrollbar = ttk.Scrollbar(self.root)
self.selected_files = tkinter.Listbox(self.root, yscrollcommand=self.scrollbar.set)
self.scrollbar.config(command=self.selected_files.yview)
示例7: test
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def test():
root = Tkinter.Tk()
root.geometry("+1+1")
Tkinter.Button(command=root.quit, text="Quit").pack()
t1 = Tester(root)
t1.top.geometry("+1+60")
t2 = Tester(root)
t2.top.geometry("+120+60")
t3 = Tester(root)
t3.top.geometry("+240+60")
i1 = Icon("ICON1")
i2 = Icon("ICON2")
i3 = Icon("ICON3")
i1.attach(t1.canvas)
i2.attach(t2.canvas)
i3.attach(t3.canvas)
root.mainloop()
示例8: _test
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def _test():
root = Tk()
text = "This is Tcl/Tk version %s" % TclVersion
if TclVersion >= 8.1:
try:
text = text + unicode("\nThis should be a cedilla: \347",
"iso-8859-1")
except NameError:
pass # no unicode support
label = Label(root, text=text)
label.pack()
test = Button(root, text="Click me!",
command=lambda root=root: root.test.configure(
text="[%s]" % root.test['text']))
test.pack()
root.test = test
quit = Button(root, text="QUIT", command=root.destroy)
quit.pack()
# The following three commands are needed so the window pops
# up on top on Windows...
root.iconify()
root.update()
root.deiconify()
root.mainloop()
示例9: test_grid_columnconfigure
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def test_grid_columnconfigure(self):
with self.assertRaises(TypeError):
self.root.grid_columnconfigure()
self.assertEqual(self.root.grid_columnconfigure(0),
{'minsize': 0, 'pad': 0, 'uniform': None, 'weight': 0})
with self.assertRaisesRegexp(TclError, 'bad option "-foo"'):
self.root.grid_columnconfigure(0, 'foo')
self.root.grid_columnconfigure((0, 3), weight=2)
with self.assertRaisesRegexp(TclError,
'must specify a single element on retrieval'):
self.root.grid_columnconfigure((0, 3))
b = tkinter.Button(self.root)
b.grid_configure(column=0, row=0)
if tcl_version >= (8, 5):
self.root.grid_columnconfigure('all', weight=3)
with self.assertRaisesRegexp(TclError, 'expected integer but got "all"'):
self.root.grid_columnconfigure('all')
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 3)
self.assertEqual(self.root.grid_columnconfigure(3, 'weight'), 2)
self.assertEqual(self.root.grid_columnconfigure(265, 'weight'), 0)
if tcl_version >= (8, 5):
self.root.grid_columnconfigure(b, weight=4)
self.assertEqual(self.root.grid_columnconfigure(0, 'weight'), 4)
示例10: test_grid_rowconfigure
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def test_grid_rowconfigure(self):
with self.assertRaises(TypeError):
self.root.grid_rowconfigure()
self.assertEqual(self.root.grid_rowconfigure(0),
{'minsize': 0, 'pad': 0, 'uniform': None, 'weight': 0})
with self.assertRaisesRegexp(TclError, 'bad option "-foo"'):
self.root.grid_rowconfigure(0, 'foo')
self.root.grid_rowconfigure((0, 3), weight=2)
with self.assertRaisesRegexp(TclError,
'must specify a single element on retrieval'):
self.root.grid_rowconfigure((0, 3))
b = tkinter.Button(self.root)
b.grid_configure(column=0, row=0)
if tcl_version >= (8, 5):
self.root.grid_rowconfigure('all', weight=3)
with self.assertRaisesRegexp(TclError, 'expected integer but got "all"'):
self.root.grid_rowconfigure('all')
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 3)
self.assertEqual(self.root.grid_rowconfigure(3, 'weight'), 2)
self.assertEqual(self.root.grid_rowconfigure(265, 'weight'), 0)
if tcl_version >= (8, 5):
self.root.grid_rowconfigure(b, weight=4)
self.assertEqual(self.root.grid_rowconfigure(0, 'weight'), 4)
示例11: test_grid_forget
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def test_grid_forget(self):
b = tkinter.Button(self.root)
c = tkinter.Button(self.root)
b.grid_configure(row=2, column=2, rowspan=2, columnspan=2,
padx=3, pady=4, sticky='ns')
self.assertEqual(self.root.grid_slaves(), [b])
b.grid_forget()
c.grid_forget()
self.assertEqual(self.root.grid_slaves(), [])
self.assertEqual(b.grid_info(), {})
b.grid_configure(row=0, column=0)
info = b.grid_info()
self.assertEqual(info['row'], self._str(0))
self.assertEqual(info['column'], self._str(0))
self.assertEqual(info['rowspan'], self._str(1))
self.assertEqual(info['columnspan'], self._str(1))
self.assertEqual(info['padx'], self._str(0))
self.assertEqual(info['pady'], self._str(0))
self.assertEqual(info['sticky'], '')
示例12: test_grid_remove
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def test_grid_remove(self):
b = tkinter.Button(self.root)
c = tkinter.Button(self.root)
b.grid_configure(row=2, column=2, rowspan=2, columnspan=2,
padx=3, pady=4, sticky='ns')
self.assertEqual(self.root.grid_slaves(), [b])
b.grid_remove()
c.grid_remove()
self.assertEqual(self.root.grid_slaves(), [])
self.assertEqual(b.grid_info(), {})
b.grid_configure(row=0, column=0)
info = b.grid_info()
self.assertEqual(info['row'], self._str(0))
self.assertEqual(info['column'], self._str(0))
self.assertEqual(info['rowspan'], self._str(2))
self.assertEqual(info['columnspan'], self._str(2))
self.assertEqual(info['padx'], self._str(3))
self.assertEqual(info['pady'], self._str(4))
self.assertEqual(info['sticky'], 'ns')
示例13: _dyn_option_menu
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def _dyn_option_menu(parent): # htest #
from Tkinter import Toplevel
top = Toplevel()
top.title("Tets dynamic option menu")
top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200,
parent.winfo_rooty() + 150))
top.focus_set()
var = StringVar(top)
var.set("Old option set") #Set the default value
dyn = DynOptionMenu(top,var, "old1","old2","old3","old4")
dyn.pack()
def update():
dyn.SetMenu(["new1","new2","new3","new4"], value="new option set")
button = Button(top, text="Change option set", command=update)
button.pack()
示例14: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def __init__(self, parent, env, canvas):
super(EnvToolbar, self).__init__(parent, relief='raised', bd=2)
# Initialize instance variables
self.env = env
self.canvas = canvas
self.running = False
self.speed = 1.0
# Create buttons and other controls
for txt, cmd in [('Step >', self.env.step),
('Run >>', self.run),
('Stop [ ]', self.stop),
('List things', self.list_things),
('List agents', self.list_agents)]:
tk.Button(self, text=txt, command=cmd).pack(side='left')
tk.Label(self, text='Speed').pack(side='left')
scale = tk.Scale(self, orient='h',
from_=(1.0), to=10.0, resolution=1.0,
command=self.set_speed)
scale.set(self.speed)
scale.pack(side='left')
示例15: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Button [as 别名]
def __init__(self, mainObj, MainWin, wWidth, wHeight, function, Object, xAxis = 10, yAxis = 10):
self.xAxis = xAxis
self.yAxis = yAxis
self.MainWindow = MainWin
self.MainObj = mainObj
if (self.callingObj != 0):
self.callingObj = Object
if (function != 0):
self.method = function
global winFrame
self.winFrame = Tkinter.Frame(self.MainWindow, width = wWidth, height = wHeight)
self.winFrame['borderwidth'] = 5
self.winFrame['relief'] = 'ridge'
self.winFrame.place(x=xAxis,y=yAxis)
#self.winFrame.configure(background="White")
self.btnQuit= Tkinter.Button(self.winFrame, text = "Close", width=8, command= lambda: self.quitProgram(self.MainWindow))
self.btnQuit.place(x=650, y=450)
self.btnNext = Tkinter.Button(self.winFrame, text = "Next", width=8, command= lambda: self.NextWindow(self.method))
self.btnNext.place(x=575, y=450)
开发者ID:ebdulrasheed,项目名称:Diabetic-Retinopathy-Feature-Extraction-using-Fundus-Images,代码行数:25,代码来源:WindowFrame.py