Twisted Qt集成
项目描述
Qt5Reactor
使用QtReactor
在运行/导入任何其他Twisted代码之前,调用
app = QApplication(sys.argv) # your code to init QtCore from twisted.application import reactors reactors.installReactor('qt5')
或
app = QApplication(sys.argv) # your code to init QtCore import qt5reactor qt5reactor.install()
测试
trial --reactor=qt5 [twisted] [twisted.test] [twisted.test.test_internet]
确保插件目录在路径中或在当前目录中,以便发现reactor。
在Python 3上测试
trial 在Python3上还不工作。请使用Twisted的Python 3测试运行器。
在调用unittest.main()之前安装reactor。
import qt5reactor qt5reactor.install() unittest.main(...)