From: Kevin A. <al...@se...> - 2005-03-07 00:21:51
|
This issue was brought up on a thread or two due to an out-of-date walkthrough. The use of select in this case is not encouraged becasue PythonCard has a built-in command menu handler to deal with exiting the application so you don't need a handler in your code. Instead, the command 'exit' is associated with the menu item used. Pretty much all the samples and tools have something like the following in their resource files and no exit handler in the user code. { 'type':'MenuItem', 'name':'menuFileExit', 'label':'E&xit\tAlt+X', 'command':'exit' } ] } So, the short story is that if you use the resource editor templates you don't need your own exit handler. If you are wanting to prompt the user before exiting, such as for saving files, you should probably put that code in an on_close handler. The relevant code for dealing with all of this is in model.py but don't worry about it unless you like looking at guts ;-) # KEA 2002-05-02 # always create at least a File menu with Quit on the Mac # so we automatically get the Apple menu... def _createMacMenu(self): mnu = wx.Menu() id = wx.NewId() mnu.Append(id, 'E&xit\tAlt+X') menubar = self.GetMenuBar() if menubar is None: menubar = wx.MenuBar() self.SetMenuBar(menubar) menubar.Append(mnu, 'File') wx.EVT_MENU(self, id, self.on_exit_command) def exit(self): """Exit the application by calling close() on the main application window.""" # regardless of whether this is a child window # or primary window of the application, this should # give us the right window to close to quit the application appWindow = self.application.getCurrentBackground() appWindow.close() def on_exit_command(self, evt): self.exit() ka |