[wxPython-users] Sending/Using Data with wx.lib.pubsub

Rich Shepard rshepard at appl-ecosys.com
Mon Oct 1 18:56:39 PDT 2007


On Mon, 1 Oct 2007, chris botos wrote:

> With Werner's comments, and the intervening time, you may have solved this
> already.  I'm a little confused about your program structure, but I have a
> couple of comments.

Chris,

   No, it's not solved. But ... I think you've clarified where the message
goes in the listener.

> The signature for the subscribe method is:
>    Publisher().subscribe(listenerMethod, topic)

> So your subscribe call is saying that there is a method "self.loadParVar"
> that will be called when the topic "self.appData.projVars" is published,
> as in your Publisher().sendMessage(...) call.  If you keep rthe subscribe
> as is, then you need a method defined like the following:

   That's correct.

> def loadParVar(self, message):
>    received_newvar = message.data
>    # received_newvar, should now be the value 'newvar'
>    # from your sendMessage call.

   I think this is what I need to add rather than a separate function (which
is how I interpreted Werner's comments).

   I'll try it tomorrow morning.

> As Werner mentioned, you need "self,newvar = message.data". The Publisher
> calls your listener function with the sendMessage data value embedded in
> the message object that is the listener function's first argument.

   Ah! That makes it much more clear.

> Also, the method projVars was not specified as the listener, so I don't
> think it is *ever* called.

   No. projVars is the message broadcast. loadParVar is the listener's
function.

   Will report back tomorrow.

Thanks,

Rich

-- 
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.        |         Accelerators(TM)
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863




More information about the wxpython-users mailing list