(You'll notice that I construct callback functions from their names in a
rather hackish manner, In stead of passing a real live method object
reference kicking and screaming between threads - this might very well
change once I've done a few tests, the code above bugs me no end - see
below)
I do it by passing the live method object. For example:
def OnFileSave(self, _):
path=self.itemtopath(self.GetSelection())
mw=self.mainwindow
mw.MakeCall( Request(mw.wt.getfile, path),
Callback(self.OnFileSaveResults, path) )
def OnFileSaveResults(self, path, exception, contents):
mw=self.mainwindow
if mw.HandleException(exception): return
bn=guihelper.basename(path)
ext=guihelper.getextension(bn)
... more code elided ....
The Request and Callback objects just wrap up the object and
parameters, and can have more supplied. They also have
assertions to verify that things are called in the right
threads.
When the Results functions are called, they have arguments appended
of the exception that happened (or None) plus any extra stuff from
the method that was called.
Roger