本文整理汇总了Python中tkinter.Frame.quit方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.quit方法的具体用法?Python Frame.quit怎么用?Python Frame.quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Frame
的用法示例。
在下文中一共展示了Frame.quit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import quit [as 别名]
class App:
def __init__(self, master):
self.frame = Frame(master)
self.frame.pack()
self.var = StringVar()
self.data_queue = Queue()
self.button = Button(self.frame, text=self.var)
self.button.pack(side=LEFT)
# start the "fetch" thread (just generate data from the clock)
self.stop_thread = False
self.thread = Thread(target=self.get_data, args=("DATA thread", self.data_queue))
self.thread.start()
# when user clicks "close" widget, call self.stop_all()
master.protocol("WM_DELETE_WINDOW", self.stop_all )
self.frame.after(500, self.updater)
def get_data(self, threadname, q):
while not self.stop_thread:
a = str(time.time())
self.data_queue.put(a)
print(f'get_data: put "{a}" to queue')
time.sleep(3)
def updater(self):
while not self.data_queue.empty():
var = self.data_queue.get()
print(f'updater: got {var}')
self.frame.after(500, self.updater) # call again after 500ms
def stop_all(self):
"""Catch the "window close event".
We must kill the thread and then call normal quit() function.
"""
self.stop_thread = True
self.thread.join() # wait for thread to stop
self.frame.quit() # call normal frame quit()