Re: app won't quit?

Charles Hartman <[email protected]>
Newsgroups gmane.comp.python.apple
Message-ID <CAJCj7-xxkN_R1nSVKiiKnf9dBuHKxW0tAq1q+M113VcLWcRh6A@mail.gmail.com>
Chris, brilliant!  Many thanks!

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'll take your word
for it (until I can test on a Windows machine) that it will also work
cross-platform.

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.



On Tue, May 28, 2013 at 12:23 PM, Chris Barker - NOAA Federal <
[email protected]> wrote:

> On Tue, May 28, 2013 at 9:11 AM, Charles Hartman <[email protected]>
> 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
>
> [email protected]
>



-- 

Charles O. Hartman
Poet in Residence
Lucy Marsh Haskell '19 Professor of Literatures in English
oak.conncoll.edu/cohar

_______________________________________________
Pythonmac-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.