本文整理汇总了Python中tkinter.Tk.mainloop方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.mainloop方法的具体用法?Python Tk.mainloop怎么用?Python Tk.mainloop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.mainloop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_automata
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def draw_automata(turing_machine=None):
w = len(turing_machine.states)
h = len(turing_machine.rules)
root = Tk()
frame = Frame(root, width=800, height=600)
frame.grid(row=0, column=0)
canvas = Canvas(frame, bg='#FFFFFF', width=800, height=600,
scrollregion=(0, -h * 15, w * 100, h * 15*3))
hbar = Scrollbar(frame, orient=HORIZONTAL)
hbar.pack(side=BOTTOM, fill=X)
hbar.config(command=canvas.xview)
vbar = Scrollbar(frame, orient=VERTICAL)
vbar.pack(side=RIGHT, fill=Y)
vbar.config(command=canvas.yview)
canvas.config(width=800, height=600)
canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
canvas.pack(side=LEFT, expand=True, fill=BOTH)
for position, state in enumerate(turing_machine.states):
state_position[state] = position
loop_occurrences[position] = 0
canvas_id = canvas.create_text(10 + 80 * position, 400, anchor="nw")
canvas.itemconfig(canvas_id, text="state-")
canvas.insert(canvas_id, 12, "%d" % state)
counter = 1
for rule in turing_machine.rules:
counter = draw_arrow(state_position[rule.current_state],
state_position[rule.next_state],
canvas, counter, rule)
root.mainloop()
示例2: goodUser
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def goodUser():
errorMsg = Tk()
goodCRN = Label(errorMsg, text="Please enter a valid Villanova username")
goodCRN.pack()
errorMsg.mainloop()
示例3: open_main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def open_main():
btn_dims = int(settings["gui"]["btn_dims"])
_xt_root = Tk()
if settings["gui"]["bypass_wm"] == "1":
_xt_root.overrideredirect(1)
_xt_root.title("Xtouchy Toolbox")
_xt_root.maxsize(btn_dims * 3, btn_dims * 3)
root_frame = ttk.Frame(_xt_root, padding="0 0 0 0", width=btn_dims * 3, height=btn_dims * 3)
root_frame.grid(column=1, row=0, sticky=("N", "W", "E", "S"))
# Screen orientation
wrkbtn = ttk.Button(root_frame, width=2, text="↑", command=lambda: rotate(0, _xt_root))
wrkbtn.place(x=btn_dims, y=0, width=btn_dims, height=btn_dims)
wrkbtn = ttk.Button(root_frame, width=2, text="↓", command=lambda: rotate(2, _xt_root))
wrkbtn.place(x=btn_dims, y=btn_dims * 2, width=btn_dims, height=btn_dims)
wrkbtn = ttk.Button(root_frame, width=2, text="←", command=lambda: rotate(1, _xt_root))
wrkbtn.place(x=0, y=btn_dims, width=btn_dims, height=btn_dims)
wrkbtn = ttk.Button(root_frame, width=2, text="→", command=lambda: rotate(3, _xt_root))
wrkbtn.place(x=btn_dims * 2, y=btn_dims, width=btn_dims, height=btn_dims)
# Close/Move button
mvbtn = ttk.Button(root_frame, width=2, text="⇱")
mvbtn.bind("<B1-Motion>", lambda x: move(x, _xt_root))
mvbtn.place(x=0, y=0, width=btn_dims, height=btn_dims)
ttk.Button(root_frame, width=2, text="X", command=lambda: reset_and_exit(_xt_root)).place(
x=btn_dims * 2, y=0, width=btn_dims, height=btn_dims
)
# Toggle virtual keyboard
tvkbtn = ttk.Button(root_frame, width=2, text="K")
tvkbtn.bind("<B1-Motion>", lambda x: move_vkeyboard(x, _xt_root))
tvkbtn.place(x=0, y=btn_dims * 2, width=btn_dims, height=btn_dims)
_xt_root.mainloop()
示例4: interactive_ask_ref
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def interactive_ask_ref(self, code, imagefn, testid):
from os import environ
if 'UNITTEST_INTERACTIVE' not in environ:
return True
from tkinter import Tk, Label, LEFT, RIGHT, BOTTOM, Button
from PIL import Image, ImageTk
self.retval = False
root = Tk()
def do_close():
root.destroy()
def do_yes():
self.retval = True
do_close()
image = Image.open(imagefn)
photo = ImageTk.PhotoImage(image)
Label(root, text='The test %s\nhave no reference.' % testid).pack()
Label(root, text='Use this image as a reference ?').pack()
Label(root, text=code, justify=LEFT).pack(side=RIGHT)
Label(root, image=photo).pack(side=LEFT)
Button(root, text='Use as reference', command=do_yes).pack(side=BOTTOM)
Button(root, text='Discard', command=do_close).pack(side=BOTTOM)
root.mainloop()
return self.retval
示例5: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def main():
root = Tk()
ex = Janela(root)
root.geometry("300x250+300+300")
center(root)
root.mainloop()
示例6: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def main():
logger.level = logs.DEBUG
usage = 'PRACMLN Query Tool'
parser = argparse.ArgumentParser(description=usage)
parser.add_argument("-i", "--mln", dest="mlnarg", help="the MLN model file to use")
parser.add_argument("-d", "--dir", dest="directory", action='store', help="the directory to start the tool from", metavar="FILE", type=str)
parser.add_argument("-x", "--emln", dest="emlnarg", help="the MLN model extension file to use")
parser.add_argument("-q", "--queries", dest="queryarg", help="queries (comma-separated)")
parser.add_argument("-e", "--evidence", dest="dbarg", help="the evidence database file")
parser.add_argument("-r", "--results-file", dest="outputfile", help="the results file to save")
parser.add_argument("--run", action="store_true", dest="run", default=False, help="run with last settings (without showing GUI)")
args = parser.parse_args()
opts_ = vars(args)
root = Tk()
conf = PRACMLNConfig(DEFAULT_CONFIG)
app = MLNQueryGUI(root, conf, directory=os.path.abspath(args.directory) if args.directory else None)
if args.run:
logger.debug('running mlnlearn without gui')
app.infer(savegeometry=False, options=opts_)
else:
root.mainloop()
示例7: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def main():
root = Tk()
root.geometry("927x550+50+50")
root.resizable(width=False, height=False)
app = Example(root)
root.mainloop()
示例8: startGui
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def startGui():
try:
import_tk()
except:
logging.error("Error Starting GUI. Could Not Find Tkinter module" + "Please install the Python Tkinter module")
return
root = Tk()
root.wm_title("Eagle V6 to KiCad Converter")
root.wm_minsize(400, 200)
frame = Frame(root, relief=RIDGE, bg="BLUE", borderwidth=2)
frame.pack(fill=BOTH, expand=1)
label = Label(frame, font=20, bg="BLUE", text="What Would You Like to Do:")
label.pack(fill=X, expand=1)
butBrd = Button(frame, text="Convert Board", command=convertBoardGUI)
butBrd.pack(fill=X, expand=1)
butLib = Button(frame, text="Convert Library", command=convertLibGUI)
butLib.pack(fill=X, expand=1)
butSch = Button(frame, text="Convert Schematic", command=convertSchGUI)
butSch.pack(fill=X, expand=1)
label = Label(frame, bg="BLUE", text="www.github.com/Trump211")
label.pack(fill=X, expand=1)
root.mainloop()
示例9: add_contact
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def add_contact(contact_list, main):
main.destroy()
top = Tk()
top.title('Add Contact')
# Box 1
Label(top, text="Enter your name:").pack(side=TOP)
ent = Entry(top)
ent.pack(side=TOP)
#Box 2
Label(top, text="Enter your number:").pack(side=TOP)
ent2 = Entry(top)
ent2.pack(side=TOP)
# Button 1
btn = Button(top, text="Submit", command=(lambda: saveContact(ent.get(), ent2.get())))
btn.pack(side=LEFT)
btn2 = Button(top, text="Exit", command=(lambda: top.destroy()))
btn2.pack(side=LEFT)
def saveContact(name, number):
temp_dict = {"name": name, "number": number}
contact_list.append(temp_dict)
showinfo(title='Success', message='Contact Added!')
del temp_dict
top.mainloop()
main_menu(contact_list)
示例10: main_menu
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def main_menu(contact_list):
main = Tk()
main.title('Contact List')
Label(main, text="Contact and Adress Book", font = "bold").pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn = Button(main, text="Show All/ Edit", command= lambda: show_all(contact_list, main))
btn.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn1 = Button(main, text="Add Contact", command= lambda: add_contact(contact_list, main))
btn1.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn2 = Button(main, text="Delete Contact",command = lambda: delete_contact(contact_list, main))
btn2.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn3 = Button(main, text="Edit Contact", command= lambda: edit_contact(contact_list, main))
btn3.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn4 = Button(main, text="Search Contacts", command= lambda: search_contacts(contact_list, main))
btn4.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn5 = Button(main, text="Format and Sort Contacts", command =lambda: format_contacts(contact_list,main))
btn5.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn6 = Button(main, text="Make A Printable List", command =lambda: printable(contact_list,main))
btn6.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn7 = Button(main,bg = "red", text="Exit Contacts", command= lambda: exit_list(contact_list, main))
btn7.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
btn8 = Button(main,text="About AppGui", command= lambda: about(main))
btn8.pack(side=TOP,padx=tk_padx,pady=tk_pady, fill = X)
main.mainloop()
示例11: deckCreation
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def deckCreation(self):
from tkinter import Tk
fenetre = Tk()
fenetre.title('Clic to add a monster to deck _ close this windows to end deck creation')
from deck_creation import DeckCreator
a=DeckCreator(fenetre,self.blocked_decks)
fenetre.mainloop()
示例12: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def main():
root = Tk(className="My graphics!")
root.geometry("400x400")
canvas = Canvas()
canvas.pack(fill=BOTH, expand=1)
# img = draw_gradient(canvas)
img = draw_danger_levels(canvas, 50, 50)
# что бы ограничить число
# if n > 255:
# n = 255
# хочу: n = 256 => 0
# n = 257 => 1
# ...
# n = 300 => 44
# 10 // 3 = 3(1)
# 10 - (10 // 3) * 3
# 10 % 3
# a % b < b
# 10 % 3 = 1
# 11 % 3 = 2
# 12 % 3 = 0
# 13 % 3 = 1
root.mainloop()
示例13: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def main():
window = Tk()
window.geometry('1366x768')
window.attributes('-fullscreen', True)
window.wm_title('GUIDO')
gui = GUI(window)
window.mainloop()
示例14: UrlDialog
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
class UrlDialog(threading.Thread):
def __init__(self, thread=None):
threading.Thread.__init__(self)
self.controlThread=thread
self.dialogRoot=Tk()
if self.dialogRoot == None:
pass
self.dialogRoot.protocol('WM_DELETE_WINDOW', self.closeBtn)
self.frame=GetUrlFrame(self.dialogRoot, self.controlThread)
if self.frame == None:
pass
def closeBtn(self):
self.controlThread.setStop()
def closeDialog(self):
self.dialogRoot.quit()
self.dialogRoot.destroy()
print("UrlDialog is terminated.")
def run(self):
print("UrlDialog is show up.")
self.dialogRoot.mainloop()
示例15: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import mainloop [as 别名]
def main(options):
"""Create GUI and perform interactions."""
root = Tk()
root.title('Oscilloscope GUI')
gui = Tdsgui(root, options)
print(type(gui))
root.mainloop()