wxpython 3.0 & multiprocessing - update GUI from background process

自作多情 提交于 2019-12-25 08:55:00

问题


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

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

I am using a pubsub subscribe method.

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

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

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.

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

Any ideas?

Thanks!

Adam


回答1:


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.



来源:https://stackoverflow.com/questions/37667606/wxpython-3-0-multiprocessing-update-gui-from-background-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!