我有一个脚本,它在tkinter的主类/循环之外/之前执行一个长时间运行的函数 我创建了一个按钮来完全退出程序根目录。销毁()但它关闭了gui,并且在我创建了可执行文件之后,该函数仍在控制台中运行,甚至作为后台进程运行。在
如何解决这个问题?在
我的脚本片段:
from tkinter import *
import threading
def download():
#downloading a video file
def stop(): # stop button to close the gui and should terminate the download function too
root.destroy()
class
...
...
...
def downloadbutton():
threading.Thread(target=download).start()
使线程成为守护进程,以便在主线程死亡时使其终止。在
例如:
^{pr2}$相关问题 更多 >
编程相关推荐