I've just written a little bit of code that seems pretty useful, so I
thought I'd share it. It's only be lightly tested, so it comes with no
guarantees. I'd be very glad to hear if anyone sees a problem with it.
Firstly, I wanted to be able to introspect a running wxPython GUI from
another thread, so I've wrapped wx.CallAfter so that you can return a
value from the GUI thread.
I've just written a little bit of code that seems pretty useful, so I
thought I'd share it. It's only be lightly tested, so it comes with no
guarantees. I'd be very glad to hear if anyone sees a problem with it.
Firstly, I wanted to be able to introspect a running wxPython GUI from
another thread, so I've wrapped wx.CallAfter so that you can return a
value from the GUI thread.
Is this sensible? Useful? If so, feel free to reuse.
You probably meant to indent the q.put line, right?
Note that since q.get() will block then this will only work if CallAfterWithReturn is called from a thread other than the UI thread. Otherwise you'll end up blocking the main loop and the UI will be frozen forever. So there should probably be an assert in there that enforces that the active thread is not the UI thread.