Python Tkinter在另一个线程上运行子进程,以避免GUI不响应 [英] Python Tkinter to run subprocess on a different thread to avoid non-responding GUI

查看:572
本文介绍了Python Tkinter在另一个线程上运行子进程,以避免GUI不响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经和Tkinter战斗了一段时间,并用光了我所引用的大部分资源.我在这里找到了几个类似的主题,但是没有一个主题带我到达需要的地方.

I've been fighting with Tkinter for a while now and have exhausted most the resources I have for referencing this. I've found a couple similar topics here but none quite bring me to where I need to be.

我运行了很长时间(实际上并不需要很长时间,只需要10到12秒钟)的python脚本即可使用CLI的子进程静默安装应用程序.子进程正常工作并且成功安装了应用程序,但是,GUI会在执行后锁定(即挂起/冻结)(并且程序不再运行后续代码).我知道我必须在这里使用线程,但是我已经尝试使用它无济于事.

I've got a long running (not long actually, it only takes 10-12 secs) python script that silently install an application using subprocess from the CLI. Subprocess worked and it successfully installed the application, however, the GUI locks (i.e hangs/freeze) after the execution (and the program no longer run the succeeding code). I know I have to use threading here but I've already tried using it to no avail.

作为学习过程的一部分,我从Github克隆了一个仓库,并将其修改为可在Windows上运行(因为它仅在MAC平台上运行),并计划对其进行扩展,这就是我遇到的问题.这是我第一次使用TKinter,如果我错过了一些愚蠢的事情或没有以正确的方式提出问题,我深表歉意.希望您能帮助我,在此先感谢您的帮助.

As part of my learning process, I cloned a repo from Github and modify it to run on Windows (since it only run in MAC platform) and planning to extend it, and this is the part where I got stucked. This is my first time to use TKinter and I apologize if I have missed something stupid or not asked the question in the right way. Hope you can help me and thank you in advance for the assistance.

可以在此链接上找到代码.

推荐答案

通过使用mtTkinter并引用此

I was able to resolved problems with my GUI by using mtTkinter and by referring to this post.

这篇关于Python Tkinter在另一个线程上运行子进程,以避免GUI不响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆