I want to create some frames in Tkinter, that should be updated periodically. Here is the code for on of them:
from Tkinter import *
import time
import random
class KopfFrame:
def __init__(self,master):
frame = Frame(master,bg="tan")
frame.pack(side=TOP,expand=YES, fill=BOTH)
self.ZeitLabel = Label(frame)
self.ZeitLabel.pack(side=RIGHT, expand=NO,ipadx=2, ipady=2)
self.refresh()
def refresh(self):
self.ZeitLabel.configure(text=time.strftime("%H:%M:%S"))
# call this function again in 5 seconds
#print(self)
self.after(5000, self.refresh)
root = Tk()
K = KopfFrame(root)
root.mainloop()
But, when I run it, I have the error:
AttributeError: KopfFrame instance has no attribute 'after'
I am pretty sure, that the way of calling is the problem. So if someone could help me, thaf I would either be thankful for a hint to a good tutorial for functions, classes an how to call an use them.
self.after()to do? Your class does not define that method, perhaps something else has such a method?