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

Robin Dunn robin at alldunn.com
Sun Dec 3 16:27:49 PST 2006


Rich Shepard wrote:

> Seems to me that the biggest problem with our use of pubsub is the 
> lack of an actual implementation to examine. Reading the API docs and
>  trying to learn just how to implement the wx.lib.pubsub() and 
> Publisher() classes is like reading a man page to learn a tool. Man 
> pages and API docs are great syntax reminders when you know what 
> you're doing, and why you're doing it, but they don't teach the 
> context.

There is some test code in the pubsub module itself.  See the test() 
function at the end.


> The trick to using wx.lib.pubsub seems to be understanding what to
> put in the parentheses of the subscribe and sendMessage methods.

http://wxpython.org/docs/api/wx.lib.pubsub.PublisherClass-class.html

Basically, it's

	Publisher().subscribe(callable, topic)

and

	Publisher().sendMessage(topic, data=None)

Where topic is a string or a tuple of strings that defines what the type 
of the message is.  The topic can be hierarchical with a topic and 
sub-topics, allowing you to have listeners that can respond generically 
to a collection of topics, or listeners that can only respond to 
specific topics.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list