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

Rich Shepard rshepard at appl-ecosys.com
Mon Oct 1 06:54:49 PDT 2007


On Mon, 1 Oct 2007, chris botos wrote:

> The subscribed function should look something like this:
>
> def SubscribedFunction(self, message):
>    newvar = message.data
>    etc.

Chris,

   I'm missing something crucial in the syntax because I cannot get it
working here.

   I use a module, config.py, as a blackboard to share variables among
modules. This is where the messages to be published are found. For
example, there's the publisher message 'projVars' in this module. config.py
is imported into all other modules and assigned to the variable
'self.appData'.

   The sending module has the line:

 	Publisher().sendMessage(self.appData.projVars, data=newvar)

   The listening module has this line:

 	Publisher().subscribe(self.loadParVar, self.appData.projVars)

In this listener module I just added the function:

 	  def projVars(self, message):
 	    self.newvar = self.appData.projVars.data

but the variable 'self.newvar' is not seen when I try to use it in another
function:

   File "/data1/eikos/fuzSetPage.py", line 391, in loadParVar
     self.dispVar = self.newvar
AttributeError: 'modFzySet' object has no attribute 'newvar'

   So I've missed something in your reply on implementing the function for
the subscribed function. Is what I've missed visible in what I include
above?

TIA,

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