[Twisted-Python] Re: Can't quit a Tkinter application on MacOS X when using Twisted; fix? workaround?

Russell E. Owen rowen at u.washington.edu
Wed Apr 8 19:23:07 EDT 2009


In article <rowen-6F098F.12205007042009 at news.gmane.org>,
 "Russell E. Owen" <rowen at u.washington.edu> wrote:

> I am trying to convert a cross-platform Python/Tkinter application to 
> use Twisted and have run into a problem: at least on MacOS X I can no 
> longer quit the application.
>....
> """Script showing failure-to-quit bug...""
> import Tkinter
> import twisted.internet.tksupport
> 
> root = Tkinter.Tk()
> twisted.internet.tksupport.install(root)
> reactor = twisted.internet.reactor
> 
> reactor.run()

Just after posting this Kevin Walzer provided an answer. The Quit menu 
on MacOS X calls the tcl "exit" function. One can easily intercept this 
in Python/Tkinter using createcommand, e.g.:

    def myQuit():
        reactor.stop()

    root.createcommand('exit', myQuit)

-- Russell





More information about the Twisted-Python mailing list