I'm trying to associate a variable with a Tkinter entry widget, in a way that:
I think you want something like this. In the example below, I created a variable
myvar and assigned it to be
textvariable of both a
Entry widgets. This way both are coupled and changes in the Entry widget will reflect automatically in Label.
You can also set trace on variables, e.g. to write to stdout.
from tkinter import * root = Tk() root.title("MyApp") myvar = StringVar() def mywarWritten(*args): print "mywarWritten",myvar.get() myvar.trace("w", mywarWritten) label = Label(root, textvariable=myvar) label.pack() text_entry = Entry(root, textvariable=myvar) text_entry.pack() root.mainloop()