简体   繁体   中英

Integrating twisted into existing pyqt GUI application

I am trying to add twisted to my already existing app. According to this and other sources, I should import qt4reactor. When I try:

app = QApplication(sys.argv)
from twisted.application import reactors
reactors.installReactor('pyqt4')

(I also tried:)

from twisted.internet import qt4reactor 

I get twisted.application.reactors.NoSuchReactor: 'pyqt4'. I can download and install qt4reactor directly, but then I can't install it after instantiating QApplication?

Also, since I am adding on twisted, the documentation states that I should use reactor.runReturn() instead of reactor.run().

from twisted.internet import reactor, protocol
reactor.listenTCP(8001, tcpFactory())
reactor.runReturn()

When I try this, I get AttributeError: 'SelectReactor' object has no attribute 'runReturn'. Is this because I am unable to install qt4reactor after instantiating QApplication?

Now qt4reactor is separate from Twisted and located here

So you need to install it first, then try:

from twisted.application import reactors
reactors.installReactor('pyqt4')

or

from qtreactor import pyqt4reactor
pyqt4reactor.install()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM