[wxpython-users] [newbie] Connection between app and frame?

Christopher Barker Chris.Barker at noaa.gov
Wed Apr 2 17:14:29 PDT 2008


Gilles wrote:
> if __name__ == '__main__':
> 	app = wx.PySimpleApp()
> 	frame = StaticTextFrame()
> 	frame.Show()
> 	app.MainLoop()

> How can the app and the frame communicate, since there doesn't seem to
> be a connection in the above code?

In what way do they need to?

Anyway, when you create an app, and call its MainLoop, it takes control 
of the, well main loop, and handles the events for everything. I also 
keeps track of if there are any Frames around, and if they are all 
destroyed, the app shuts down.

In short, all the communication required is done behind the scenes for you.

If you do need to explicitly communicate, you can put a reference to the 
frame in the app, a reference to the app in the frame, or use 
wx.GetApp() to get a reference to the app anywhere. Plus other options...

-Chris






-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the wxpython-users mailing list