如何在python中使用多个子过程而不冻结TKINTER窗口(Mainloop)?
我有2个子过程,可以在TKINTER程序中调用FFMPEG,两个子过程彼此链接。但是,当我正常启动过程时,主TKINTER窗口变得无反应并冻结,直到子过程结束为止。我使用了线程,以使TKINTER窗口不受影响,但是在这种情况下,第二个子过程不需等待即可立即杀死旧的子过程。我该如何解决?
这是我使用螺纹的方式:
def process():
subprocess.Popen(f'"{ffmpeg}"-i "{inputpath}" {parameters} -y "{outputpath}"', shell=True)
thread = threading.Thread(target=process)
thread.start()
我想要的是以一个序列运行子过程(意味着第二个子进程仅在完成第一个子过程后才应运行),并且也不冻结主TKINTER窗口。
I have 2 subprocess that calls ffmpeg in a tkinter program, both subprocesses are linked to each other. But when I start the processes normally then the main tkinter window become unresponsive and freezes until the subprocesses end. I used threading so that the tkinter window is not affected but in that case the second subprocess starts immediately killing the old subprocess without waiting. How can I fix this?
Here is how I used the threading:
def process():
subprocess.Popen(f'"{ffmpeg}"-i "{inputpath}" {parameters} -y "{outputpath}"', shell=True)
thread = threading.Thread(target=process)
thread.start()
What I want is to run the subprocesses in background in one sequence (means the second subprocess should run only after completing the first one) and also without freezing the main tkinter window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论