[wxPython-users] Re: "Pushing" Data to Modules
Rich Shepard
rshepard at appl-ecosys.com
Sun Dec 3 12:14:39 PST 2006
On Sat, 2 Dec 2006, Werner F. Bruhin wrote:
> Not that I am expert on this but here is a revised version of what I used to
> get a hang of pubsub.
Werner,
Looking at what you sent, and the wx.lib.pubsub API doc page is getting me
closer, and with less code than you used. The error I'm getting now is:
File
"/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/lib/pubsub.py",
line 670, in validate
raise TypeError, 'Listener '+`listener+' lacking arguments!'
TypeError: Listener <bound method modPolicy.setWidgets of
<policyPage.modPolicy; proxy of C++ wxPanel instance at
_18544408_p_wxPanel>> lacking arguments!
so it appears that by 'importing wx.lib.pubsub as Publisher' I've exposed
what's neede. Now it's a matter of structuring the arguments properly.
Unfortunately, the API doc page uses ellipses in the parentheses rather than
clue sticks for beginning users like me.
In config.py (the application-visible variables) I have added:
projOpen = 1 # publisher message that a project file's opened
Next, in DBmethods.DBtools().openDB() I have:
self.pubData = self.appData.projName
self.Publisher().sendMessage(projOpen, self.pubData)
which are probably mal-formed. I'm not sure what to put in the arguments to
self.Publisher().sendMessage().
Finally, in modPolicy().__init__() I have the line generating the error:
self.polSub = Publisher().subscribe(self.setWidgets, self.appData.projOpen)
I tried to follow the model in your example of having the
Publisher().subscribe parameters of the function to call and the message
that triggers calling that function. Obviously, I missed.
The trick to using wx.lib.pubsub seems to be understanding what to put in
the parentheses of the subscribe and sendMessage methods.
Thanks,
Rich
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc.(TM) | Accelerator
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
More information about the wxpython-users
mailing list