Best way to communicate between wx frames/panels


What is the proper approach for communicating between modules like multiple panels, frames etc…

I ask because I have a frame where I instantiate different panels and I need the panels to pass data between themselves as well as to the frame class. I’m a little lost because I see this as a hierarchy issue as shown below:

frame obj
-> panel1
-> panel2
-> custom_data_obj

So this is what I’m seeing conceptually and need to share data/information between the panels (for example panel1 and panel2 as well as pass data “up” to the main frame class.

So far all I can think of is the enact queues/threads or pass an “object” reference/handle between them but that seems messy. Because I’m not a software engineer I am sure I’m missing something obvious.

I use PubSub (publisher-subscriber) to do this. Basically the class that needs to send the information calls pub.sendMessage() and the class that needs to receive the information calls pub.subscribe() to register a handler method to process the information. If appropriate, multiple classes can register to receive the same message. I find it works very well.


At our RIDE project we also use PyPubSub, please note that now it is not integrated in wxPython, but is a PiPy package. Current version is compatible only with Python 3.

Hi Guys! THank you very much for the replies!

I ended up finding the PubSub module to be a fantastic solution for what I needed to do.

Thanks again!

1 Like