Python Tkinter after() Only Executing Once

后端 未结 1 1049
时光取名叫无心
时光取名叫无心 2020-12-11 11:18

Something that seems like it should be so simple is giving me quite an issue. I have a Tkinter GUI that I am trying to update at regular intervals. Specifically I am delet

相关标签:
1条回答
  • 2020-12-11 11:36

    Place a call to after at the end of update:

    def __init__(self, frame):       
        self.frame = frame
        ...
        self.frame.after(1000, self.update)
    
    def update(self): 
        ...
        self.frame.after(1000, self.update)
    

    This is the way after works. It only queues the callback (e.g. self.update) once. Per the docs:

    The callback is only called once for each call to this method. To keep calling the callback, you need to reregister the callback inside itself

    0 讨论(0)
提交回复
热议问题