Making python/tkinter label widget update?

You’ll want to set the label’s textvariable with a StringVar; when the StringVar changes (by you calling myStringVar.set("text here")), then the label’s text also gets updated. And yes, I agree, this is a strange way to do things.

See the Tkinter Book for a little more information on this:

You can associate a Tkinter variable with a label. When the contents of the variable changes, the label is automatically updated:

v = StringVar()
Label(master, textvariable=v).pack()

v.set("New Text!")

Leave a Comment