Re: [Pythonmac-SIG] app won't quit?
On 27 May 2013 16:26, Charles Hartman co...@conncoll.edu wrote: I'm coming back to all of this after years away, so I'm sure I'm missing something simple. I've brought an old app into the current world: Python 2.7.5 OS 10.8.3 wxPython 2.9.4.0 py2app 0.7.3 and I rebuilt my setup.py to current specifications. The resulting app works fine (though it's enormous!), but it won't respond to a Quit command (keyboard or menu). The menu-bar header (with my app's name) flashes, but nothing else happens. Thanks for any help. In wx the app will close if all top level frames are closed, so if some are left open it wont, did you override some close event handlers possibly by binding to EVT_CLOSE? Also the app will stay running as long as any non-daemon threads are running- are you using any threading in the app? -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
Thanks, but no. My app never touches EV_CLOSE, and it doesn't do threading at all. On Tue, May 28, 2013 at 7:34 AM, Paul Wiseman poal...@gmail.com wrote: On 27 May 2013 16:26, Charles Hartman co...@conncoll.edu wrote: I'm coming back to all of this after years away, so I'm sure I'm missing something simple. I've brought an old app into the current world: Python 2.7.5 OS 10.8.3 wxPython 2.9.4.0 py2app 0.7.3 and I rebuilt my setup.py to current specifications. The resulting app works fine (though it's enormous!), but it won't respond to a Quit command (keyboard or menu). The menu-bar header (with my app's name) flashes, but nothing else happens. Thanks for any help. In wx the app will close if all top level frames are closed, so if some are left open it wont, did you override some close event handlers possibly by binding to EVT_CLOSE? Also the app will stay running as long as any non-daemon threads are running- are you using any threading in the app? -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
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. (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.) 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? Binding to wx.EVT_CLOSE doesn't seem to do anything. On Tue, May 28, 2013 at 1:07 AM, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: On Mon, May 27, 2013 at 10:54 AM, Charles Hartman co...@conncoll.edu wrote: You have pointed me to something bizarre. This is on a Mac. On Mac, though quitting the app closes all top-level windows, closing all top-level windos doesn't quit the app. yes, that's the Mac convension, but teh wx cnvension is for an app to quit when all the top-level windows are closed. If you actually want the proper mac behaviour, you need to create a dummy Frame to keep the App alive (and give it a menu bar...) -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
On Tue, May 28, 2013 at 5:33 AM, Charles Hartman co...@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/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
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.) item = self.fileMenu.Append(-1,'Exit','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. On Tue, May 28, 2013 at 11:54 AM, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: On Tue, May 28, 2013 at 5:33 AM, Charles Hartman co...@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/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
Just found this: http://wiki.wxwidgets.org/WxMac-specific_topics#When_to_close_the_program maybe it will help. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
On Tue, May 28, 2013 at 9:11 AM, Charles Hartman co...@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,'Exit','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,'Exit','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/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov MacApp.py Description: Binary data ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
On 28/05/2013 18:11, Charles Hartman 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.) item = self.fileMenu.Append(-1,'Exit','Terminate the program') Shouldn't that be: item = self.fileMenu.Append(wx.ID_EXIT,'Exit','Terminate the program') To get correct cross platform behaviour. http://wxpython.org/Phoenix/docs/html/MenuItem.html?highlight=menu#MenuItem.__init__ Werner ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
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,'Exit','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 chris.bar...@noaa.gov wrote: On Tue, May 28, 2013 at 9:11 AM, Charles Hartman co...@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,'Exit','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,'Exit','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/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
On 27 May, 2013, at 17:26, Charles Hartman co...@conncoll.edu wrote: I'm coming back to all of this after years away, so I'm sure I'm missing something simple. I've brought an old app into the current world: Python 2.7.5 OS 10.8.3 wxPython 2.9.4.0 py2app 0.7.3 and I rebuilt my setup.py to current specifications. The resulting app works fine (though it's enormous!), but it won't respond to a Quit command (keyboard or menu). The menu-bar header (with my app's name) flashes, but nothing else happens. This might be caused by an unhandled exception. Have you tried running the app from the command-line (yourapp.app/Contents/MacOS/yourapp)? Ronald Thanks for any help. -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
I've observed this with the wxPy demo...may be a ex bug. Sent from my iPhone On May 27, 2013, at 11:26 AM, Charles Hartman co...@conncoll.edu wrote: I'm coming back to all of this after years away, so I'm sure I'm missing something simple. I've brought an old app into the current world: Python 2.7.5 OS 10.8.3 wxPython 2.9.4.0 py2app 0.7.3 and I rebuilt my setup.py to current specifications. The resulting app works fine (though it's enormous!), but it won't respond to a Quit command (keyboard or menu). The menu-bar header (with my app's name) flashes, but nothing else happens. Thanks for any help. -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
Wxpython bug, that is. Sent from my iPhone On May 27, 2013, at 11:26 AM, Charles Hartman co...@conncoll.edu wrote: I'm coming back to all of this after years away, so I'm sure I'm missing something simple. I've brought an old app into the current world: Python 2.7.5 OS 10.8.3 wxPython 2.9.4.0 py2app 0.7.3 and I rebuilt my setup.py to current specifications. The resulting app works fine (though it's enormous!), but it won't respond to a Quit command (keyboard or menu). The menu-bar header (with my app's name) flashes, but nothing else happens. Thanks for any help. -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
Running it from the command line doesn't change anything; nothing shows up in Terminal except a message saying that PySimpleApp is now deprecated in wxPython. But when I changed to the standard App instead, nothing changed. Nothing shows up in Console either. Following Kevin's suggestion, I'm posting the problem on the wxPython list. On Mon, May 27, 2013 at 12:38 PM, Ronald Oussoren ronaldousso...@mac.comwrote: On 27 May, 2013, at 17:26, Charles Hartman co...@conncoll.edu wrote: I'm coming back to all of this after years away, so I'm sure I'm missing something simple. I've brought an old app into the current world: Python 2.7.5 OS 10.8.3 wxPython 2.9.4.0 py2app 0.7.3 and I rebuilt my setup.py to current specifications. The resulting app works fine (though it's enormous!), but it won't respond to a Quit command (keyboard or menu). The menu-bar header (with my app's name) flashes, but nothing else happens. This might be caused by an unhandled exception. Have you tried running the app from the command-line (yourapp.app/Contents/MacOS/yourapp)? Ronald Thanks for any help. -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
Hi, On 27/05/2013 19:22, Charles Hartman wrote: Running it from the command line doesn't change anything; nothing shows up in Terminal except a message saying that PySimpleApp is now deprecated in wxPython. But when I changed to the standard App instead, nothing changed. Nothing shows up in Console either. Following Kevin's suggestion, I'm posting the problem on the wxPython list. Could it be that you have any top level windows still open, or a timer not stopped or a tray icon which is still around? Werner ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] app won't quit?
You have pointed me to something bizarre. This is on a Mac. On Mac, though quitting the app closes all top-level windows, closing all top-level windos doesn't quit the app. So your question looks irrelevant—but it isn't! If I close my app's only window, I see that the app has quit! Have I somehow discovered the secret to making a Mac behave like a Windows machine? (Am I happy?) On Mon, May 27, 2013 at 1:39 PM, Werner F. Bruhin werner.bru...@free.frwrote: Hi, On 27/05/2013 19:22, Charles Hartman wrote: Running it from the command line doesn't change anything; nothing shows up in Terminal except a message saying that PySimpleApp is now deprecated in wxPython. But when I changed to the standard App instead, nothing changed. Nothing shows up in Console either. Following Kevin's suggestion, I'm posting the problem on the wxPython list. Could it be that you have any top level windows still open, or a timer not stopped or a tray icon which is still around? Werner __**_ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/**mailman/listinfo/pythonmac-sighttp://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/**mailman/options/Pythonmac-SIGhttp://mail.python.org/mailman/options/Pythonmac-SIG -- Charles O. Hartman Poet in Residence Lucy Marsh Haskell '19 Professor of Literatures in English oak.conncoll.edu/cohar ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG