[Pythonmac-SIG] app won't quit?

Chris Barker - NOAA Federal chris.barker at noaa.gov
Tue May 28 17:54:34 CEST 2013


On Tue, May 28, 2013 at 5:33 AM, Charles Hartman <cohar at conncoll.edu> wrote:
> When I updated my app, I switched from the deprecated wx.PySimpleApp, which
> had the right default behavior on Mac, to wx.App, which apparently doesn't.

hmm -- I'm pretty sure that PYSipleApp is deprecated because it
doesn't actually do anything -- though it way chance a default or two.
One to look at is crating the app:

app = wx.App(True) will create an extra wx.Frame to capture stout.

app = wx.App(False) will not, and will not re-direct stdout.

> (The docs say "You should normally exit the main loop (and the application)
> by deleting the top window."  What's "normal" for a Windows user would
> baffle my Mac users, and vice versa—but never mind.)

yup -- and wx follows the Windows/GTK conventions here, so you have to
kludge a bit to get proper Mac behavior

  I see I can call
> wxGetApp().ExitMainLoop.  But in response to what?  What is the event sent
> by the Mac keyboard or menu Quit command?

I'm still a bit confused -- if you build an app the regular wx way,
and it works right on Windows and Linux, then you should get an app
that goes away when you want it to stay alive, not the other way
around -- so I would expect you to need to figure out how to keep it
alive. IIUC, the way to do that is to create a dummy wx.Frame -- it
will keep the app alive, and give you a menu bar. See this SO thread:

http://stackoverflow.com/questions/2934435/how-to-change-the-osx-menubar-in-wxpython-without-any-opened-window

>  Binding to wx.EVT_CLOSE doesn't seem to do anything.

where are you binding that? to the Frame? It's usually a wx.frame event.

Take a look at this:

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

Which does not address the question at hand, but may address other
questions...And if/when  you find a solution it would be great if  you
would add it to that page!

-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