Mar-27-2022, 06:54 AM
(This post was last modified: Mar-27-2022, 06:55 AM by Coricoco_fr.)
Hello,
I'm not sure I understood your request. Do you want to do this? :
I'm not sure I understood your request. Do you want to do this? :
import tkinter as tk class Window(tk.Tk): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.count = tk.IntVar() self.count.set(0) self.label = tk.Label(self, text='Hello World') self.label.pack() def counter(self): self.count.set(self.count.get()+1) self.label['text'] = self.count.get() self.after(1000, self.counter) if __name__ == '__main__': app = Window() def trace(*event): print("app.couter in main", app.count.get()) app.count.trace_add("write", trace) app.after(1000, app.counter) app.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^^.