[wxPython-users] how to do multi-window interactions?

Jorgen Bodde jorgen.maillist at gmail.com
Wed May 2 00:53:54 PDT 2007


If I understood your problem correctly, I think wx.lib.pubsub is what
you are looking for.

What I do in my app is subscribing to a global Publisher() class which
distributes the sent message to all listeners.

Simply do something like this;

from wx.lib.pubsub import Publisher

in frame #1

def __init__(self, ...):
    Publisher().subscribe( self.__OnCommit, ('signal', 'commit') )

def __OnCommit(self, message):
    print 'Received dat:', message.data

And in frame #2 on the commit button for example;

def __OnCommitButton(self, event):
    # the __mObjectData is a class passed to frame #1
    Publisher().sendMessage( ('signal', 'commit'), self.__mObjectData)

This way you can send to frame #1, and when you require sending to
frame #2 from frame #1 you can make another signal type (the tuple
('signal', 'commit') ) which it listens to.

HTH,
- Jorgen




More information about the wxpython-users mailing list