使用线程计时器Python运行While循环

时间:2018-06-25 10:34:10

标签: python-3.x while-loop timer python-multithreading

我有一个while循环,在该循环中我使用线程计时器,这样每隔20秒就会发生一些事情,但是我不想每次进入循环时都创建一个线程。 我想要这样的东西:

def timer_function():
    return True

while TRUE:
    t = Timer(20.0, timer_function)
    if "timer has run the 20 seconds":
        execute_some_other_threads()
        reset_the_timer_to_20_seconds
    main_window.update_idletasks()
    main_window.update()

有什么方法可以使计时器函数返回一个值,使用它,然后在我的tkinter窗口中连续运行更新时再次启动计时器吗?

0 个答案:

没有答案
相关问题