小编Sar*_*son的帖子

tkinter 退出/退出/终止函数线程退出主循环

我有这个脚本,它在 tkinter 中的主类/循环之外/之前执行一个长时间运行的函数,并且我创建了一个按钮来使用 root.destroy() 完全退出程序,但它关闭了 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()
Run Code Online (Sandbox Code Playgroud)

python multithreading tkinter python-multithreading python-2.7

0
推荐指数
1
解决办法
2481
查看次数