本文整理汇总了Python中Tkinter.Tk.mainloop方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.mainloop方法的具体用法?Python Tk.mainloop怎么用?Python Tk.mainloop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Tk
的用法示例。
在下文中一共展示了Tk.mainloop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
global drawing_area
root = Tk()
root.title("Drawer")
drawing_area = Canvas(root, width=300, height=300, bg="white")
# Binding Events to the canvas
drawing_area.bind("<B1-Motion>", drag)
drawing_area.bind("<ButtonRelease-1>", drag_end)
drawing_area.pack()
# Buttons
# Quit Button
b1 = Button(root, text="Quit")
b1.pack()
b1.bind("<Button-1>", quit)
# Clear Button
b2 = Button(root, text="Clear")
b2.pack()
b2.bind("<Button-1>", clear)
# Save Button
b3 = Button(root, text="Save")
b3.pack()
b3.bind("<Button-1>", save)
root.mainloop()
示例2: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
global cnx
root = Tk()
root.geometry("900x600+100+100")
cnx = conectar()
app = Example(root)
root.mainloop()
示例3: 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
示例4: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
app = "netconvert"
appOptions = parse_help(app)
# appOptions = []
root = Tk()
app = Launcher(root, app, appOptions)
root.mainloop()
示例5: checkExit
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def checkExit():
root = Tk()
root.geometry("200x90+300+300")
app = Escape(root)
root.mainloop()
result = app.getStatus()
return result
示例6: optionFilter
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def optionFilter():
global racine
racine = Tk()
fenetre = filterswindow(racine)
racine.geometry("500x300+200+0")
racine.mainloop()
示例7: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
tk = Tk()
menuBar = Pmw.MainMenuBar(tk)
def command():
print('Pressed')
menuBar.addmenu('File', 'File')
menuBar.addmenuitem(
'File', 'command', 'Close',
command=command,
label='Close'
)
insertmenuitem(
menuBar,
'File', 'command', 'Open',
command=command,
index=0,
label='Open'
)
tk.configure(menu=menuBar)
tk.mainloop()
示例8: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
root = Tk()
app = App(root)
root.geometry("610x610+100+200")
root.mainloop()
示例9: demo
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def demo():
from Tkinter import Tk, Frame, Button, BOTH, LEFT
root = Tk()
root.title("wckCalendar")
def echo():
print (view.getselection())
view = Calendar(root, font="verdana", background="white", command=echo)
view.pack(fill=BOTH, expand=1)
buttonbox = Frame(root)
def previous():
date = view.getdate()
if date.month == 1:
view.setdate(date.year-1, 12)
else:
view.setdate(date.year, date.month-1)
def next():
date = view.getdate()
if date.month == 12:
view.setdate(date.year+1, 1)
else:
view.setdate(date.year, date.month+1)
b = Button(buttonbox, text="previous", command=previous, width=10)
b.pack(side=LEFT)
b = Button(buttonbox, text="next", command=next, width=10)
b.pack(side=LEFT)
buttonbox.pack(expand=1, padx=2, pady=2)
root.mainloop()
示例10: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
x_size = 0
y_size = 0
gates = []
ports = []
root = Tk()
layout_fl = open(os.path.dirname(os.path.abspath(__file__)) \
+ "/layout.txt","r")
for ln in layout_fl:
is_match = re.match(r"x_size(\d+)y_size(\d+)",ln)
if (is_match):
x_size = int(is_match.group(1))
y_size = int(is_match.group(2))
is_match = re.match(r"gatename(.+)x(\d+)y(\d+)",ln)
if(is_match):
gate = is_match.group(1),\
int(is_match.group(2)),\
int(is_match.group(3))
gates.append(gate)
is_match = re.match(r"portname(.+)x(\d+)y(\d+)",ln)
if(is_match):
port = is_match.group(1),\
int(is_match.group(2)),\
int(is_match.group(3))
ports.append(port)
sz = ""
sz = str(x_size*scale_c+2*margin) + "x" + \
str(y_size*scale_c+2*margin)
#sz = "800x450"
grid = x_size,y_size
ex = Draw_Layout(root,grid,gates,ports)
#root.bind('<Key>',key);
root.geometry(sz)
root.mainloop()
示例11: main_tkinter
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main_tkinter(gen):
from Tkinter import Tk
t = TkinterTask.generator(gen)
root = Tk()
for s in "+-*/":
t(s).start()
root.mainloop()
示例12: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
root = Tk()
app = PhyUI(root, 1000, 500)
app.set_viewport(Vect2D(0, 0), Vect2D(200, 100))
all_ = []
# Four boundaries
all_.append(simulate.Ball(
radius = 20, shift = Vect2D(5 * 10 + 10, 2 * 10 + 10),
velo = Vect2D(0, 0), accel = Vect2D(0, 0),
mass = 5, app = app))
all_.append(simulate.Ball(
radius = 20, shift = Vect2D(0 * 10 + 10, 5 * 10 + 10),
velo = Vect2D(5, 0), accel = Vect2D(0, 0),
mass = 5, app = app))
# Some balls for testing
for i in all_:
app.register_trigger(i, 5, 0.007)
# Register in display callback
root.mainloop()
示例13: demo
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def demo():
root = Tk()
root.bind('<Control-q>', lambda e: root.destroy())
table = Table(root, 'Word Synset Hypernym Hyponym'.split(),
column_weights=[0, 1, 1, 1],
reprfunc=(lambda i,j,s: ' %s' % s))
table.pack(expand=True, fill='both')
from nltk.corpus import wordnet
from nltk.corpus import brown
for word, pos in sorted(set(brown.tagged_words()[:500])):
if pos[0] != 'N': continue
word = word.lower()
for synset in wordnet.synsets(word):
hyper = (synset.hypernyms()+[''])[0]
hypo = (synset.hyponyms()+[''])[0]
table.append([word,
getattr(synset, 'definition', '*none*'),
getattr(hyper, 'definition', '*none*'),
getattr(hypo, 'definition', '*none*')])
table.columnconfig('Word', background='#afa')
table.columnconfig('Synset', background='#efe')
table.columnconfig('Hypernym', background='#fee')
table.columnconfig('Hyponym', background='#ffe')
for row in range(len(table)):
for column in ('Hypernym', 'Hyponym'):
if table[row, column] == '*none*':
table.itemconfig(row, column, foreground='#666',
selectforeground='#666')
root.mainloop()
示例14: test
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def test():
from Tkinter import Tk, Text
root = Tk()
class MyEditWin:
def __init__(self, text):
self.text = text
self.flist = None
self.text.bind("<Control-o>", self.open)
self.text.bind("<Control-s>", self.save)
self.text.bind("<Alt-s>", self.save_as)
self.text.bind("<Alt-z>", self.save_a_copy)
def get_saved(self): return 0
def set_saved(self, flag): pass
def reset_undo(self): pass
def open(self, event):
self.text.event_generate("<<open-window-from-file>>")
def save(self, event):
self.text.event_generate("<<save-window>>")
def save_as(self, event):
self.text.event_generate("<<save-window-as-file>>")
def save_a_copy(self, event):
self.text.event_generate("<<save-copy-of-window-as-file>>")
text = Text(root)
text.pack()
text.focus_set()
editwin = MyEditWin(text)
io = IOBinding(editwin)
root.mainloop()
示例15: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import mainloop [as 别名]
def main():
root = Tk()
root.geometry("500x350+300+300")
app = Example(root)
root.mainloop()