本文整理汇总了Python中ttk.Button类的典型用法代码示例。如果您正苦于以下问题:Python Button类的具体用法?Python Button怎么用?Python Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Button类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: networkServerUI
def networkServerUI(self):
try:
self.parent.title("Mighty Cracker")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
#load buttons and labels
self.closeButton= Button(self, text="Close Program", command=self.confirmExit)
self.closeButton.pack(side=BOTTOM, padx=5, pady=5)
self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackNetworkServerUI_LoadInitUI)
self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5)
self.networkServerLabel= Label(self, text="Network Server")
self.networkServerLabel.pack(side=TOP, padx=5, pady=5)
self.selectCrackingMethodLabel= Label(self, text="Select Your Cracking Method")
self.selectCrackingMethodLabel.pack(side=TOP, padx=5, pady=5)
self.dictionaryCrackingMethodButton= Button(self, text="Dictionary", command=self.unpackNetworkServerUI_LoadNetworkDictionaryUI)
self.dictionaryCrackingMethodButton.pack(side=TOP, padx=5, pady=5)
self.bruteForceCrackingMethodButton= Button(self, text="Brute-Force (default)", command=self.unpackNetwrokServerUI_LoadNetworkBruteForceUI)
self.bruteForceCrackingMethodButton.pack(side=TOP, padx=5, pady=5)
self.rainbowTableCrackingMethodButton= Button(self, text="Rainbow Table", command=self.unpackNetworkServerUI_LoadNetworkRainbowTableUI)
self.rainbowTableCrackingMethodButton.pack(side=TOP, padx=5, pady=5)
except Exception as inst:
print "============================================================================================="
print "GUI ERROR: An exception was thrown in networkServerUI definition Try block"
#the exception instance
print type(inst)
#srguments stored in .args
print inst.args
#_str_ allows args tto be printed directly
print inst
print "============================================================================================="
示例2: networkModeUI
def networkModeUI(self):
try:
self.parent.title("Mighty Cracker")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
#load buttons and labels
self.closeButton= Button(self, text="Close Program", command=self.confirmExit)
self.closeButton.pack(side=BOTTOM, padx=5, pady=5)
self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackNetworkModeUI_LoadInitUI)
self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5)
self.networkModeLabel= Label(self, text="Network Mode: Server/Client Selection Screen")
self.networkModeLabel.pack(side=TOP, padx=5, pady=5)
self.selectNetworkModuleLabel= Label(self, text="Select Server or Client")
self.selectNetworkModuleLabel.pack(side=TOP, padx=5, pady=5)
self.serverModuleButton= Button(self, text="I am the Server", command= self.unpackNetworkModeUI_LoadNetworkServerUI)
self.serverModuleButton.pack(side=TOP, padx=5, pady=5)
self.clientModuleButton= Button(self, text="I am a Client", command= self.unpackNetworkModeUI_LoadNetworkClientUI)
self.clientModuleButton.pack(side=TOP, padx=5, pady=5)
except Exception as inst:
print "============================================================================================="
print "GUI ERROR: An exception was thrown in networkModeUI definition Try block"
#the exception instance
print type(inst)
#srguments stored in .args
print inst.args
#_str_ allows args tto be printed directly
print inst
print "============================================================================================="
示例3: networkClientUI
def networkClientUI(self):
try:
self.parent.title("Mighty Cracker")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
#load buttons and labels
self.closeButton= Button(self, text="Close Program", command=self.confirmExit)
self.closeButton.pack(side=BOTTOM, padx=5, pady=5)
self.returnToInitUIButton= Button(self, text="Return to Main Menu", command=self.unpackNetworkClientUI_LoadInitUI)
self.returnToInitUIButton.pack(side=BOTTOM, padx=5, pady=5)
self.networkClientLabel= Label(self, text="Network Client")
self.networkClientLabel.pack(side=TOP, padx=5, pady=5)
self.insertServerIPLabel= Label(self, text="Enter in the Server's IP:")
self.insertServerIPLabel.pack(side=TOP, padx=5, pady=5)
self.insertServerIPTextfield= Entry(self, bd=5)
self.insertServerIPTextfield.pack(side=TOP, padx=5, pady=5)
#TODO allow right click for pasting into box
self.startClientButton= Button(self, text="Start Client", command=lambda: self.startClient(str(self.insertServerIPTextfield.get())))
self.startClientButton.pack(side=TOP, padx=5, pady=5)
except Exception as inst:
print "============================================================================================="
print "GUI ERROR: An exception was thrown in networkClientUI definition Try block"
#the exception instance
print type(inst)
#srguments stored in .args
print inst.args
#_str_ allows args tto be printed directly
print inst
print "============================================================================================="
示例4: initUI
def initUI(self):
self.parent.title("Windows")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
# Configures padding between items in application
self.columnconfigure(1, weight=1)
self.columnconfigure(3, pad=7)
self.rowconfigure(3, weight=1)
self.rowconfigure(5, pad=7)
self.lbl = Label(self, text="Windows")
self.lbl.grid(sticky=W, pady=4, padx=5)
self.area = Label(self)
# Column and row span make box go to that column/row
self.area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E+W+S+N)
self.abtn = Button(self, text="Connect", command = self.connect)
# self.abtn["command"] = update_box()
self.abtn.grid(row=1, column=3)
self.cbtn = Button(self, text="Close")
self.cbtn.grid(row=2, column=3, pady=4)
self.hbtn = Button(self, text="Help")
self.hbtn.grid(row=5, column=0, padx=5)
self.obtn = Button(self, text="Open")
self.obtn.grid(row=5, column=3)
示例5: initUI
def initUI(self):
self.parent.title("Book downloader")
self.style = Style()
self.style.theme_use("default")
framesearch = Frame(self)
framesearch.pack(fill=BOTH)
search_label = Label(framesearch, text="Filter books:", padx=5, pady=5, width=15)
search_label.pack(side=LEFT)
self.search_entry = Entry(framesearch)
self.search_entry.pack(side=RIGHT, fill=X)
self.search_entry.bind("<Return>", self.searchHandler)
#self.search_entry.bind("<Key>", self.searchHandler)
framelist = Frame(self, relief=RAISED, borderwidth=1)
framelist.pack(fill=BOTH, expand=True)
self.lb = Listbox(framelist, height=30)
scrollbar = Scrollbar(framelist)
scrollbar.pack(side=RIGHT, fill=Y)
self.lb.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=self.lb.yview)
self.loadLibrary()
for b in self.book_list:
self.lb.insert(END, b[0])
self.lb.pack(fill=BOTH)
self.pack(fill=BOTH, expand=True)
DownButton = Button(self, text="Download", command=self.downloadAction)
DownButton.pack(side=RIGHT)
示例6: initUI
def initUI(self):
self.parent.title("Batch Geocoder")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
quitButton = Button(self, text="Quit", command=self.quit)
quitButton.place(x=50, y=50)
menubar = Menu(self.parent)
self.parent.config(menu=menubar)
scrollbar = Scrollbar(self)
scrollbar.pack( side = RIGHT, fill=Y)
fileMenu = Menu(menubar)
fileMenu.add_command(label="Run", command=self.onOpen)
fileMenu.add_command(label="Exit", underline=0, command=self.onExit)
menubar.add_cascade(label="File", menu=fileMenu)
#menubar.add_command(label="Run", command=self.runScript)
self.txt = Text(self, yscrollcommand = scrollbar.set)
scrollbar.config( command = self.txt.yview )
self.txt.pack(fill=BOTH, expand=1)
示例7: initUI
def initUI(self):
information = Label(self,text = " \n Information on "+business_list[int(business_index)]['name']+"\n \n Located at: \n " + business_list[int(business_index)]['full_address'] )
information.pack()
num_reviews = Label(self, text = "Number of Reviews : " + str(business_list[int(business_index)]['review_count']) )
num_reviews.pack()
type = Label(self, text = "Type of Restaurant : " + str(business_list[int(business_index)]['type']) )
type.pack()
cat = business_list[int(business_index)]['categories']
text_cat = ''
for item in cat:
text_cat = text_cat + ", " + item
categories = Label(self, text = "Category of the resaurtant "+ text_cat )
categories.pack()
w = Label(self, text=" \n Write a Review for "+business_list[int(business_index)]['name'] )
w.pack()
e = Text(self, height=20, width=100)
e.insert(END,"Insert Review Here")
e.pack()
b = Button(self, text="Submit Review",command=lambda: self.tostars(e.get(1.0, END)))
b.pack(side=BOTTOM, fill=BOTH)
self.pack(fill=BOTH, expand=1)
示例8: __init__
def __init__(self, name, add_handler, remove_handler, master=None):
"""
Creates a ListFrame with the given name as its title.
add_handler and remove_handler are functions to be called
when items are added or removed, and should relay the information
back to the Searcher (or whatever object actually uses the list).
"""
LabelFrame.__init__(self, master)
self['text'] = name
self.add_handler = add_handler
self.remove_handler = remove_handler
self.list = Listbox(self)
self.list.grid(row=0, columnspan=2)
# Tkinter does not automatically close the right-click menu for us,
# so we must close it when the user clicks away from the menu.
self.list.bind("<Button-1>", lambda event: self.context_menu.unpost())
self.list.bind("<Button-3>", self.open_menu)
self.context_menu = Menu(self, tearoff=0)
self.context_menu.add_command(label="Remove", command=self.remove)
self.input = Entry(self)
self.input.bind("<Return>", lambda event: self.add())
self.input.grid(row=1, columnspan=2)
self.add_button = Button(self)
self.add_button['text'] = "Add"
self.add_button['command'] = self.add
self.add_button.grid(row=2, column=0, sticky=W+E)
self.remove_button = Button(self)
self.remove_button['text'] = "Remove"
self.remove_button['command'] = self.remove
self.remove_button.grid(row=2, column=1, sticky=W+E)
示例9: initUI
def initUI(self):
try:
self.parent.title("Mighty Cracker")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
#load buttons and labels
self.closeButton= Button(self, text="Close Program", command=self.confirmExit)
self.closeButton.pack(side=BOTTOM, padx=5, pady=5)
self.mainMenuLabel= Label(self, text="Main Menu")
self.mainMenuLabel.pack(side=TOP,padx=5, pady=5)
self.singleModeButton= Button(self, text="Single Computer Mode", command=self.unpackInitUI_LoadSingleComputerMode)
self.singleModeButton.pack(side=TOP, padx=5, pady=5)
self.networkModeButton= Button(self, text="Networking Mode", command=self.unpackInitUI_LoadNetworkMode)
self.networkModeButton.pack(side=TOP, padx=5, pady=5)
except Exception as inst:
print "============================================================================================="
print "GUI ERROR: An exception was thrown in initUI definition Try block"
#the exception instance
print type(inst)
#srguments stored in .args
print inst.args
#_str_ allows args tto be printed directly
print inst
print "============================================================================================="
示例10: init_ui
def init_ui(self):
self.parent.title("Activity Logger")
self.parent.focusmodel("active")
self.style = Style()
self.style.theme_use("aqua")
self.combo_text = StringVar()
cb = self.register(self.combo_complete)
self.combo = Combobox(self,
textvariable=self.combo_text,
validate="all",
validatecommand=(cb, '%P'))
self.combo['values'] = ["Food", "Email", "Web"]
self.combo.pack(side=TOP, padx=5, pady=5, fill=X, expand=0)
#self.entry = Text(self, bg="white", height="5")
#self.entry.pack(side=TOP, padx=5, pady=5, fill=BOTH, expand=1)
self.pack(fill=BOTH, expand=1)
self.centre()
self.ok = Button(self, text="Ok", command=self.do_ok)
self.ok.pack(side=RIGHT, padx=5, pady=5)
self.journal = Button(self, text="Journal", command=self.do_journal)
self.journal.pack(side=RIGHT, padx=5, pady=5)
self.exit = Button(self, text="Exit", command=self.do_exit)
self.exit.pack(side=RIGHT, padx=5, pady=5)
示例11: TabServices
class TabServices(Frame):
def __init__(self, parent, txt=dict()):
"""Instanciating the output workbook."""
self.parent = parent
Frame.__init__(self)
# variables
self.url_srv = StringVar(self,
'http://suite.opengeo.org/geoserver/wfs?request=GetCapabilities')
# widgets
self.lb_url_srv = Label(self,
text='Web service URL GetCapabilities: ')
self.ent_url_srv = Entry(self,
width=75,
textvariable=self.url_srv)
self.btn_check_srv = Button(self, text="youhou")
# widgets placement
self.lb_url_srv.grid(row=0, column=0,
sticky="NSWE", padx=2, pady=2)
self.ent_url_srv.grid(row=0, column=1,
sticky="NSWE", padx=2, pady=2)
self.btn_check_srv.grid(row=0, column=2,
sticky="NSWE", padx=2, pady=2)
示例12: initUI
def initUI(self):
self.parent.title("FirstGUI")
self.pack(fill=BOTH, expand=1)
quitButton = Button(self, text="Quit", command=self.quit)
quitButton.place(x=100, y=100)
示例13: showLoading
def showLoading(self):
self.attemptedMarkov = True
popup = Toplevel()
text = Message(popup, text="The Markov Generator is still loading!\n\nText will show up when loaded!")
text.pack()
closePop = Button(popup, text="Okay!", command=popup.destroy)
closePop.pack()
示例14: __init__
class MyButton:
#Класс для улучшения читаемости кода однотипных элементов кнопок.
def __init__(self, place_class, string_class, command_class):
#При создании принимается место прикрепления виджета, строковое значение для надписи
#и строковое для установления команды при нажатии.
self.button_class = Button(place_class, width = 30, text = string_class, command = command_class)
self.button_class.pack(side = LEFT)
示例15: MainFrame
class MainFrame(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("GSN Control Panel")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
self.turnOnBtn = Button(self, text="Turn On")
self.turnOnBtn["command"] = self.turnOn
self.turnOnBtn.grid(row=0, column=0)
self.turnOffBtn = Button(self, text="Turn Off")
self.turnOffBtn["command"] = self.turnOff
self.turnOffBtn.grid(row=0, column=1)
def turnOn(self):
host.enqueue({"SM":"GSN_SM", "action":"turnOn", "gsnId":GSNID, "localIP":IP, "localPort":int(PORT)})
def turnOff(self):
host.enqueue({"SM":"GSN_SM", "action":"turnOff"})