[wxPython-users] Re: "Pushing" Data to Modules

Werner F. Bruhin werner.bruhin at free.fr
Mon Dec 4 01:28:19 PST 2006


Hi Rich,

Rich Shepard wrote:
> On Sun, 3 Dec 2006, Robin Dunn wrote:
>
>> Basically, it's
>>     Publisher().subscribe(callable, topic)
>> and
>>     Publisher().sendMessage(topic, data=None)
>
>   Well, darn! That's what I thought I have.
>
>   In the OpenDB() function I have
>
>     Publisher().sendMessage(self.appData.projOpen, data=None)
>
> and in the class modPolicy()'s __init__() method I have
>
>     Publisher().subscribe(self.setWidgets, self.appData.projOpen)
>
> with setWidgets() a function that places values in the treeCtrl.
>
>   But the error is still that the subscribe method has no arguments:
>
>   File "/data1/eikos/policyPage.py", line 124, in __init__
>     Publisher().subscribe(self.setWidgets, self.appData.projOpen)
>   File
> "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/lib/pubsub.py",
> line 638, in subscribe
>     self.validate(listener)
>   File
> "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/lib/pubsub.py",
> line 670, in validate
>     raise TypeError, 'Listener '+istener+' lacking arguments!'
> TypeError: Listener <bound method modPolicy.setWidgets of
> <policyPage.modPolicy; proxy of C++ wxPanel instance at
> _00534408_p_wxPanel>> lacking arguments!
>
>   Should the Publisher().subscribe() be located somewhere other than 
> in the
> init method?

I think the problem is with your "self.setWidgets" definition.

In the sample code if I change:

def MyPrint(msg):

to
def MyPrint():

I get the following exception:
Traceback (most recent call last):
  File "pubsubApp.py", line 6, in ?
    import pubsubtest
  File "C:\Dev\BoaTest04\pubsub\pubsubtest.py", line 4, in ?
    import mypublisher as mypub
  File "C:\Dev\BoaTest04\pubsub\mypublisher.py", line 36, in ?
    InitMyPublisher()
  File "C:\Dev\BoaTest04\pubsub\mypublisher.py", line 27, in InitMyPublisher
    publisher.subscribe(MyPrint, '')
  File "C:\Python24\lib\site-packages\wx-2.6-msw-ansi\wx\lib\pubsub.py", 
line 677, in subscribe
    self.validate(listener)
  File "C:\Python24\lib\site-packages\wx-2.6-msw-ansi\wx\lib\pubsub.py", 
line 709, in validate
    raise TypeError, 'Listener '+`listener`+' lacking arguments!'
TypeError: Listener <function MyPrint at 0x009ED1B0> lacking arguments!

Werner
>
> Rich
>






More information about the wxpython-users mailing list