[Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application?

Kevin Walzer kw at codebykevin.com
Tue Apr 7 22:08:14 CEST 2009


Russell E. Owen wrote:
> Anyone know how to redefine what the File>Quit menu item does on MacOS X 
> using Aqua Tcl/Tk?
> 
> I am trying to convert a cross-platform application to use Twisted, and 
> unfortunately this seems to make the pre-existing Quit menu item on 
> MacOS X do *nothing*. I can't quit the application without using ctrl-C 
> or closing the root window (not an option for this application).
> 
> I have tried to configure that menu item, but tk does not seem to know 
> that it exists (the index of the last menu item is too small).
> 
> Any suggestions would be most welcome.
> 
> -- Russell

The pre-defined "Quit" menu entry that comes with Tk/Aqua is in the 
application menu, not the file menu. In my two Python/Tk apps, hitting 
"Command-Q" quits them without any code on my part--Tk is invoking the 
standard "quit" event.

If "Quit" is in the "File" menu, then it's not the pre-existing 
one--you'l have to handle that yourself.

If I'm misreading you, and you are talking about the "Quit" entry in the 
app menu, try something like this:

self.bind('Command-Key-Q', lamdba event: sys.exit())

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


More information about the Tkinter-discuss mailing list