[Pythonmac-SIG] app won't quit?

Chris Barker - NOAA Federal chris.barker at noaa.gov
Tue May 28 18:23:31 CEST 2013


On Tue, May 28, 2013 at 9:11 AM, Charles Hartman <cohar at conncoll.edu> wrote:
> Thanks, Chris.  My app has a wx.Frame (subclassed, of course).  It's there
> that I've tried Binding EVT_CLOSE, but a breakpoint in the method I find is
> never reached at all, including when I use menu or keyboard to Quit.  On way
> I've tried is this snippet I got from wxPyWiki.  (The line that purports to
> add an Exit item to the File menu does not in fact do that.  Mac still keeps
> Quit in the MyApp menu.)

right -- wx tries hard to make you app more Mac-like by moving menu
items around. If a menu item has ID ID_EXIT, it will get moved, maybe
also if it is called "exit" or "quit". But you want that, yes?

>         item = self.fileMenu.Append(-1,'E&xit','Terminate the program')
>         self.Bind(wx.EVT_MENU, self.OnClose, item)
>         if wx.Platform=="__WXMAC__":
>             wx.App.SetMacExitMenuItemId(item.GetId())
>
> This doesn't work either; OnClose() is never reached.

This is odd, but a few pointers. Try:

        item = self.fileMenu.Append(ex.ID_EXIT,'E&xit','Terminate the program')
        self.Bind(wx.EVT_MENU, self.OnClose, item)
## this shouldn't be needed if you use the ID above.
>         if wx.Platform=="__WXMAC__":
>             wx.App.SetMacExitMenuItemId(item.GetId())

I think you're going to need to put together a sample app. The
enclosed works. (I'd like to add the multiple-frame, app stays alive
thing, though...)

Oh, and you may want to try the "Widget Inspection Tool" -- it may
show you something.

-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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MacApp.py
Type: application/octet-stream
Size: 4512 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20130528/db9db9d6/attachment-0001.obj>


More information about the Pythonmac-SIG mailing list