I think that I do not quite understand when the tkinter variable notifies the observer, and when not. In particular, I do not understand why the following example calls only fonce:
from tkinter import Tk, IntVar
Tk()
x = IntVar()
def f(*_):
print("f called")
x.set(1)
x.trace("w", f)
x.set(0)
print(x.get())
I expect it to either stop responding during printing f calledtime and time again, or throw an exception at some point. Instead, it prints f calledexactly once, prints 1and exits.
source
share