蟒蛇 + PyQt 程序冻结
我编写了 PyQt 应用程序。启动后我关闭它(GUI),但计时器不会停止,Python 有时会冻结。唯一解冻它的方法是 - Ctrl-C,之后会出现以下消息:
<块引用> <块引用>回溯(最近一次调用最后一次): 文件“”,第 262 行,timerEvent 中 键盘中断
计时器不会再次停止,并且 CPython 运行速度非常慢。如何避免这个问题呢?
编辑: 我将killTimer()添加到源代码中,但事情并没有改变那么多。 CPython 很慢并且有时会挂起。如何完全销毁所有PyQt对象?
Mw = TMainWindow()
TimerId = Mw.startTimer(25)
QApp.exec_()
Mw.killTimer(TimerId)
I wrote PyQt application. After it's start I close it (GUI), but timer don't stops and Python sometimes freezes. Only thing to unfreeze it - Ctrl-C, after which following message appears:
Traceback (most recent call last):
File "", line 262, in timerEvent
KeyboardInterrupt
timer don't stops again, and CPython works very slowly. How to avoid this problem?
EDIT:
I added killTimer() to source but things don't changed that much. CPython is slow and hangs sometimes. How to fully destroy all PyQt objects?
Mw = TMainWindow()
TimerId = Mw.startTimer(25)
QApp.exec_()
Mw.killTimer(TimerId)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有进一步的信息,这完全是猜测。 GUI 关闭时应用程序不退出的最常见原因之一是
QApplication::quitOnLastWindowClosed
属性设置为 false。Without further information this is a complete guess. One of the more frequent reasons that an application doesn't exit when the GUI is closed is because of
QApplication::quitOnLastWindowClosed
property being set to false.