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

Kevin Walzer kw at codebykevin.com
Tue Apr 7 23:29:40 CEST 2009


Russell Owen wrote:

> 
> The normal Quit menu item has always worked fine for me until I switched 
> to using Twisted framework. Now it does nothing.

I wonder if it's a conflict between the Tk and Twisted event loops? 
Doesn't Twisted have its own event loop? (Never used Twisted myself.)

> 
>> If...you are talking about the "Quit" entry in the app menu, try 
>> something like this:
>>
>> self.bind('Command-Key-Q', lamdba event: sys.exit())
> 
> 
> What should self be to bind this application-wide (for all windows and 
> widgets)? Root doesn't seem to accept key events.


My apps inherit directly from Tk/Tkinter itself:

class quickwhoApp(Tk):

     def __init__(self, parent):
         Tk.__init__(self, parent)
         try:
             self.tk.call('console', 'hide')
         except TclError:
             pass

if __name__== '__main__':
     app = quickwhoApp(None)
     app.mainloop()

Binding to self works for me under these circumstances.


> 
> (Also, although this is much better than nothing, presumably it will not 
> actually support the Quit menu item? If so, I hope to find a more 
> thorough solution.)
> 
> -- Russell

Not sure--as I saisd, I think adding Twisted to the mix makes things 
more complex.

Kevin


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


More information about the Tkinter-discuss mailing list