Tkinter — executing functions over time

前端 未结 2 1649
时光取名叫无心
时光取名叫无心 2020-11-21 13:23

I\'m trying to figure out how the tkinter control flow works.

I want to display a rectangle and to make it blink three times. I wrote this code, but it doesn\'t work

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-21 13:40

    Each widget has an 'after' function - that is to say it can call a another function after a specified time period - So, what you would want to do is call:

    root.after( 1000, blink )
    

    If you want it to be a repeating call, just call 'after' again inside your blink function. The only problem you will have is passing arguments to blink - maybe look at using lamda inside of 'after' for that.

提交回复
热议问题