[Twisted-Python] Conflict between Tkinter.mainloop() and twisted.internet.reactor.run()

hz hanks hankshz at gmail.com
Fri Mar 30 18:48:55 EDT 2012

The answer is here:


use tksupport.install() instead of Tkinter.run()

2012/3/30 hz hanks <hankshz at gmail.com>:
> Hi all,
> I'm writing a program with Twisted and use Tkinter to realize the GUI
> interface. However, it seems that I can not run both
> Tkinter.mainloop() and twisted.internet.reactor.run() in the same
> thread because they will block the other. I tried to program a button
> in Tkinter and when the button is pressed, it will start a new thread
> using module threading, and call a function with the contend of
>        reactor.listenTCP(PORT, file_trans_service.getFileTransCtrlServFactory()
>        reactor.run()
> But it will raise an exception as follows:
> --- <exception caught here> ---
>  File "F:\Python27\lib\site-packages\twisted\internet\base.py", line
> 426, in _continueFiring
>    callable(*args, **kwargs)
>  File "F:\Python27\lib\site-packages\twisted\internet\base.py", line
> 1164, in _reallyStartRunning
>    self._handleSignals()
>  File "F:\Python27\lib\site-packages\twisted\internet\posixbase.py",
> line 292, in _handleSignals
>    _SignalReactorMixin._handleSignals(self)
>  File "F:\Python27\lib\site-packages\twisted\internet\base.py", line
> 1129, in _handleSignals
>    signal.signal(signal.SIGINT, self.sigInt)
> exceptions.ValueError: signal only works in main thread
> And I also tried to run twisted.internet.reactor.run() in the main
> thread, and use module threading or reactor.callInThread() to run
> Tkinter.mainloop(). The interface will be displayed, but not
> responding.
> Any one knows how to solve this problem? I just need a Template to
> realize the Twisted with GUI. Very appreciated!
> Best,
> Hanks

More information about the Twisted-Python mailing list