蟒蛇 + PyQt 程序冻结

发布于 2024-08-30 15:43:16 字数 482 浏览 4 评论 0原文

我编写了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

メ斷腸人バ 2024-09-06 15:43:16

如果没有进一步的信息,这完全是猜测。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文