[pyGEF-develop] Notification / pubsub / sigslot / traits
Status: Pre-Alpha
Brought to you by:
hrgerber
|
From: <pyg...@li...> - 2007-06-14 00:53:47
|
I see what you mean about using traits as a messaging system now.
You can do:
sender.on_trait_changed(callback, name="trait_name")
sender.trait_name = True # calls callback
Somebody on the wxPython list pointed me to Louie, which is a pubsub
framework available via easy_install.
The basic pattern there is
louie.connect(callback, "a.signal", sender)
louie.send("a.signal", sender, <whatever args you want>)
Here 'a.signal' can be any string or hashable python object.
And the sender doesn't have to be any special class either. It's just an
object that specifies the origin. So every button can have a "clicked"
signal, but if you louie.connect(callback, "clicked", cool_button) you only
get callbacks from cool_button. If you to know the sender then you have to
pass it at send time:
louie.send("a.signal", obj, sender=obj)
But at the end of the day do accomplish more or less the same thing.
--bb
|