Jan-22-2020, 08:12 AM
Hello!
Have a nice day, everyone!
There was a problem: previously did
change of time by functions, without classes - everything worked well. I decided to make classes and I don’t know how to use the root.after function to display the current time correctly.
This is part of my code, but everything is clear from it.
Have a nice day, everyone!
There was a problem: previously did
change of time by functions, without classes - everything worked well. I decided to make classes and I don’t know how to use the root.after function to display the current time correctly.
This is part of my code, but everything is clear from it.
import tkinter as tk from tkinter import* from time import strftime root = tk.Tk() root.geometry('200x200+20+20') class StartWindow: #start page loading def __init__(self, master): self.canvas1 = Canvas(master, width=200, height=200) self.canvas1.place(x=0, y=0) game = TopWindow(self.canvas1) class TopWindow: #display top window def __init__(self, canvas1): self.canvas1 = canvas1 self.time_value = self.canvas1.create_text(50, 25, text='time') time1 = Set_time(self.canvas1, self.time_value) class Set_time: #current time change def __init__(self, canvas1, time_value): self.canvas1 = canvas1 self.time_value = time_value self.time_2 = strftime('%H:%M:%S') self.canvas1.itemconfig(self.time_value, text = self.time_2) #root.after(100, self.canvas1, self.time_value) ????????????????????? st = StartWindow(root) root.mainloop()