[Pythonmac-SIG] app won't quit?

Chris Barker - NOAA Federal chris.barker at noaa.gov
Tue May 28 22:00:05 CEST 2013


On Tue, May 28, 2013 at 9:50 AM, Charles Hartman <cohar at conncoll.edu> wrote:
\
> I included these lines in the __init__ for my app's Frame (or rather, in a
> long SetupGUI method that is called by __init__):
>
>         item = self.fileMenu.Append(wx.ID_EXIT,'E&xit','Terminate the
> program')
>         self.Bind(wx.EVT_MENU, self.OnClose, item)
>
> Then farther down in the Frame code I have this method:
>
>     def OnClose(self, item):
>         wx.GetApp().ExitMainLoop()
>
> That gets exactly the behavior Mac users are used to.

I'm still confused as to why you need that call to ExitMainLoop....

And why this gets you Mac behavior -- the usual Mac behavior is for
the App NOT to exit when all its Frames are closed.

> for it (until I can test on a Windows machine) that it will also work
> cross-platform.

note that on any platform, I think this will cause the closing of the
Frame to kill the App, whether or not there are other frames open --
if you app supports having more than one frame open at a time, you
probably don't want that.


> Should this be posted somewhere where newbies (like me again) who are trying
> to combine Mac, Python, and wxPython can find it? It is certainly not
> obvious.

This Wiki Page:

http://wiki.wxpython.org/Optimizing%20for%20Mac%20OS%20X

Perhaps the term "Optimizing" is a mistake in that title -- these
aren't really optimizations...

(note the the ID_EXIT is there already, but not the call to MainLoop
(which I still don't quite get the need for..)

-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 Pythonmac-SIG mailing list