Mar-27-2022, 07:52 AM
This is a better practice.
import tkinter as tk class Window(tk.Frame): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.count = 1 self.label = tk.Label(self, text='Hello World') self.label.pack() self.counter() def counter(self): self.label['text'] = self.count self.count += 1 self.after(1000, self.counter) if __name__ == '__main__': root = tk.Tk() bt = tk.Button(root, text="Press to stop", command=quit) bt.grid() app = Window() app.grid() root.mainloop()
I speak Python but I don't speak English (I just read it a little). If I express myself badly, please blame the translator^^.