wxpython 3.0及更高版本多重处理-从后台进程更新GUI [英] wxpython 3.0 & multiprocessing - update GUI from background process

查看:109
本文介绍了wxpython 3.0及更高版本多重处理-从后台进程更新GUI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的wxpython GUI应用程序中,我有一个rsync任务,该任务是作为multiprocessing.Process启动的.

From my wxpython GUI app I have an rsync task that I kick off as a multiprocessing.Process.

想法是使用此后台进程的恒定输出更新wx.textCtrl.

The idea is to update a wx.textCtrl with the constant output from this background process.

我正在使用pubsub订阅方法.

I am using a pubsub subscribe method.

功能正常,但是我无法更新textCtrl.

The functions work fine but I can't get the textCtrl to update.

如果我使用CallAfter方法,则会出现此崩溃/错误:

If I use a CallAfter method I get this crash/error:

该过程已经分叉,您不能使用此CoreFoundation 安全功能.您必须exec().打断 THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY ___ YOU_MUST_EXEC () 进行调试.

The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). Break on THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC() to debug.

如果我不使用该方法,而是尝试将文本直接附加到textctrl上,则不会发生任何事情.

If I don't use that method and I try to append the text directly to the textctrl nothing happens.

有什么想法吗?

谢谢!

亚当

推荐答案

问题是子进程无法写回主进程.使用队列将消息传递回主进程,并从等待队列消息的计时器或后台线程中更新控件.

The problem is that the child process can't write back to the main process. Use a queue to pass messages back to the main process, and update the control from within a timer or a background thread that waits for messages from the queue.

这篇关于wxpython 3.0及更高版本多重处理-从后台进程更新GUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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