【发布时间】:2014-05-19 13:45:07
【问题描述】:
我的应用具有以下结构:
import tkinter as tk
from threading import Thread
class MyWindow(tk.Frame):
... # constructor, methods etc.
def main():
window = MyWindow()
Thread(target=window.mainloop).start()
... # repeatedly draw stuff on the window, no event handling, no interaction
main()
应用程序运行完美,但如果我按下 X(关闭)按钮,它会关闭窗口,但不会停止进程,有时甚至会抛出 TclError。
编写这样的应用程序的正确方法是什么?如何以线程安全的方式或没有线程的方式编写它?
【问题讨论】:
标签: python multithreading tkinter python-multithreading