我正在用python创建一个程序,并使用pyqt。我目前正在使用QTimer,我想每秒钟打印一次“timer works”,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")
下面是一个简单的演示,演示如何创建一个计时器,该计时器在固定的超时次数后停止。
相关问题 更多 >
编程相关推荐