让 PyQt 应用程序控制一切。反应堆怎么用?
我有一个 django 应用程序,通过 Twisted 提供服务,它还提供其他服务(主要是三个套接字)。
我需要让它在 Windows 下工作,我决定编写一个 PyQt4 应用程序,它的作用与 Windows 的 Apache Service Monitor 非常相似。
我无法将twistedreactor连接到pyqt应用程序reactor,因此任何关于此的提示也将受到欢迎。
现在我有这种架构:
- QMainWindow,其中 __ init __() 具有 log.addObserver(callBack) 函数和小部件。
- Twisted 初始值设定项 类,它扩展了 QtCore.QThread 并在不同的线程中工作。
- django 应用程序在 Twisted 上运行。
我需要了解如何运行反应器,因为从 QtCore.QThread 调用reactor.start()根本不起作用,这给了我:
exceptions.ValueError: signal only works in main thread
另外,我正在询问您对应用程序设计的意见,确实如此这对你来说有意义吗?
I've a django application, served via Twisted, which also serves ohter services (three sockets, mainly).
I need to have it working under windows, and I decide to write a PyQt4 application which acts quite like Apache Service Monitor for windows.
I was not able to connect twisted reactor to pyqt application reactor, so any hint on this will be welcome too.
Now I've this kind of architecture:
- QMainWindow which, in __ init __() has the log.addObserver(callBack) function, and the widget.
- Twisted initializer class which extends QtCore.QThread and works in a different thread.
- the django app which runs over Twisted.
I need to understand how to run the reactor, becouse calling reactor.start() from QtCore.QThread works not at all, giving me:
exceptions.ValueError: signal only works in main thread
Also I'm asking your opinion on the design of applications, does it makes sense for you?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我完全理解您的设计,但我可以说的是您只需要在应用程序中使用一个反应器。反应器是应用程序的主(事件)循环。而且,我认为,这个反应器应该是您的情况下的 QTreactor 。
I'm not sure I totally understand your design but what I can say is that you need to use only one reactor in an application. The reactor is the main (event) loop of the application. And, I think, this reactor should be the QTReactor in your case.