I have two frames in different files (main frame and settings frame), and I’d like to know if it’s possible to pass a variable from a frame in a file to another in the other file. I need it for when I change a value on the settings frame so it can change the main frame actively.
I tried importing them:
main.py:
from sett import settingsframe
for open the settings frame from the main frame…
sett.py:
from main import mainframe
but I get an import error (as I thought).
If both frames belong to the same
wx.Appthen I think you can use PubSub to send variables back and forth. Unlikewx.Eventobjects, I don’t beleive PubSub is tied to parent/child hierarchies. I use PubSub in my application. Although I only have one frame, I do use it to send variables between panels and to/from my database wrapper class.That link has some example code to get you going so you can see if it will work for you.
Alternatively, since both frames are in the same loop you could do something really hackish like have the frames set each other as a
selfvariable. I’d suggest trying PubSub first.