【发布时间】:2021-09-27 08:53:04
【问题描述】:
我写了一个简单的应用程序,我想每秒钟打印一次日志消息。
我打开一个终端并运行它,它运行良好。但是当我用鼠标点击终端时,它不会打印日志消息,除非我在终端中打印Enter。
守则
import logging
from PyQt5.QtCore import *
logging.basicConfig(level=logging.DEBUG)
app = QCoreApplication([])
timer = QTimer()
timer.setInterval(1000)
timer.timeout.connect(lambda: logging.info("abc"))
timer.start()
app.exec()
【问题讨论】:
-
你在 Windows 上吗?
-
是的,我用的是win10系统。
-
正如另一条评论中所解释的,问题与 PyQt 无关,而是与 Windows 命令提示符有关:Why is my command prompt freezing on Windows 10?。禁用该功能,输出将不再被阻止。
标签: python-3.x terminal pyqt5