小编Jay*_*pee的帖子

PyQt5 QTimer 计数直到特定秒

我正在用 python 创建一个程序,我正在使用 pyqt。我目前正在使用 QTimer,我想每秒钟打印一次“计时器工作”并在 5 秒后停止打印。这是我的代码:

timers = []
def thread_func():
    print("Thread works")
    timer = QtCore.QTimer()
    timer.timeout.connect(timer_func)
    timer.start(1000)
    print(timer.remainingTime())
    print(timer.isActive())
    timers.append(timer)

def timer_func():
    print("Timer works")
Run Code Online (Sandbox Code Playgroud)

python pyqt qtimer pyqt5

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

pyqt ×1

pyqt5 ×1

python ×1

qtimer ×1