Search code examples
pythonwxpythonmultiprocessingpublish-subscribe

wxpython 3.0 & multiprocessing - update GUI from background process


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


Solution

  • 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.