tkinter exit/quit/killing函数线程超出主循环

2024-04-25 09:49:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个脚本,它在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()

Tags: the函数import程序脚本可执行文件tkinterdownload