messages across a gulf

I'm sure this is standard but I haven't it yet. I have a PySimpleApp that instantiates two Frames, one of which owns an STC and the other a TextCtrl. Most business is done within one or the other. But a mouse double-click in one or the other needs to control the display in the other. Neither Frame has a parent (None), though the app owns both Frames.

What's the best way to open a channel of communication between one Frame's STC and the other's TextCtrl? Some sort of global-variable kludge? More likely, invent a message-type that the one can send and the other can understand? If that's the proper way to proceed, where can I find details? In the Demo, EventManager looks promising but I don't see enough about how to use it. Nothing about it in the wxDocsViewer docs.

Charles Hartman

Charles Hartman wrote:

I'm sure this is standard but I haven't it yet. I have a PySimpleApp that instantiates two Frames, one of which owns an STC and the other a TextCtrl. Most business is done within one or the other. But a mouse double-click in one or the other needs to control the display in the other. Neither Frame has a parent (None), though the app owns both Frames.

What's the best way to open a channel of communication between one Frame's STC and the other's TextCtrl? Some sort of global-variable kludge? More likely, invent a message-type that the one can send and the other can understand? If that's the proper way to proceed, where can I find details? In the Demo, EventManager looks promising but I don't see enough about how to use it. Nothing about it in the wxDocsViewer docs.

There are a few ways to do it with varying levels of complexity. Just use whatever makes sense for your situation.

* On the simple end of the specturm you can just give each of the windows a reference to the other, then when something happens in one you can just call a method of the other, self.otherWin.DoSomething().

* At the other end of the specturm you can totally uncouple them and use the wx.lib.pubsub (which EventManager also uses) and each window can publish certain messages and subscribe to others.

* In the middle you can have an object in the middle that knows about both windows and brokers requests between them.

ยทยทยท

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