Tracing Entry that uses a StringVar has no effect on Label
The problem is that you are using a local variable for a_var
, and on the Mac it is getting garbage-collected. Save a reference to the variable (eg: self.a_var
rather than just a_var
).
self.a_var = StringVar() self.a_var.trace("w", self.var_changed) self.entry = Entry(frame,textvariable=self.a_var) self.entry.pack()
Note: if all you want is to keep a label and entry in sync, you don't need to use a trace. You can link them by giving them both the same textvariable
:
self.entry = Entry(frame, textvariable=self.a_var)self.label = Label(frame, textvariable=self.a_var)