0
我的应用程序的结构如下:无法在X按钮关闭多线程的Tkinter应用
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
。
什么是写这样的应用程序的正确方法?如何以线程安全的方式写入或不使用线程?