[Pythonmac-SIG] Tk Aqua (Quit binding)

Kevin Walzer kw at codebykevin.com
Thu Jan 17 22:03:18 CET 2008


Kenneth Miller wrote:
> 
>      Using the native python installation with Aqua Tk I've noticed that it
> automatically generates a "Quit" button/function. Is there any way that I
> can bind my own quit function to this call?
>

I do something like this:


     #shut down
     def shutDown(self):
         fetchanswer = askyesno(title='Quit', message='Do you really 
wish to quit Phynchronicity?', detail='Quitting will terminate all 
operations.', parent=self, icon='info')
         if fetchanswer:
             sys.exit()

	And then bind it like thus:

        self.protocol('WM_DELETE_WINDOW', self.shutDown)
         self.bind('<Command-Key-Q>', lambda event: self.shutDown())
         self.bind('<Command-Key-q>', lambda event: self.shutDown())

HTH,
Kevin
-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com


More information about the Pythonmac-SIG mailing list