Enables calling wxPython object methods from any thread.
As you may know, in wxPython, invoking methods that alter the GUI from any thread other than the one running the main event loop can cause issues. Normally, other threads must use events to communicate with the GUI thread. Although there are some built-in shortcuts to help with this, such as wx.CallAfter, these aren't always ideal and they don't cover all aspects of a function call.
With wxAnyThread, you can safely and easily invoke methods from any thread without worrying about thread safety. This module works transparently and propagates return values and exceptions back to the calling thread.
The main interface of wxAnyThread is the "anythread" decorator. When applied to a method, it makes the method safe to call from any thread. Here's an example:
```
class MyFrame(wx.Frame):
@anythread
def GetSomeData():
dlg = MyQueryDialog(self,"Enter some data")
if dlg.ShowModal() == wx.ID_OK:
resp = dlg.GetResponse()
return int(resp)
else:
raise NoDataEnteredError()
```
In this example, the GetSomeData method can now be directly invoked from any thread. The calling thread will block while the main GUI thread shows the dialog, and will then receive a return value or exception as appropriate.
Overall, if you're looking for a way to simplify your wxPython development and make your methods callable from any thread, wxAnyThread is definitely worth checking out.
Version 0.1.3: N/A