0

I am using tkinter and several components in my project are using this pattern using after.

class DClock():

    def __init__(self, parent, parent_width):
        super().__init__()                
        self.lbl = Label(parent, 
            font = ('Verdana', 40, 'bold'), 
            background = 'red', 
            foreground = 'white', text='')

        string = strftime('%H:%M:%S') 
        self.lbl.config(text = string)
        
        self.lbl.pack(anchor = 'center')

        self.refresh()
        
        
    def refresh(self):
        string = strftime('%H:%M:%S') 
        self.lbl.config(text = string)
        self.lbl.after(1000, self.refresh)

Refresh works nice for 15 minutes, but after that starts updating after 2 seconds, and later on the update period increases. In 30 minutes it is 3 seconds and so on.

What may be the problem?

Easy Points
  • 115
  • 6
  • Does your example reproduce the problem? You will definitely get better answers if you include a [mre]. –  Sep 04 '20 at 11:08
  • i am creating one. – Easy Points Sep 04 '20 at 11:46
  • You may want to look at this to debug by yourself. https://stackoverflow.com/questions/63118430/create-a-main-loop-with-tkinter/63118515#63118515 – Thingamabobs Sep 04 '20 at 13:51
  • This code does not behave as you describe. I created a single instance of this class and I have been keeping an eye on it for 45 minutes and it updates once every second. There must be more to the problem then you are showing us. Please provide a _complete_ [mcve]. – Bryan Oakley Sep 04 '20 at 15:46
  • Hi, I am trying to isolate the problem @BryanOakley, since the project is bigger it will take a little time for me to provide short code to reproduce. – Easy Points Sep 04 '20 at 18:43

0 Answers0