Skip to content Skip to sidebar Skip to footer

Getting Tkinter Labels To Update When Variable Changes

I'm trying to build an app with pythons tkinter module. Currently I'm trying to get a labels displayed text to change when a radiobutton is selected. I have the labels text set to

Solution 1:

In this code, Label updates every click of Radiobutton using command option of Radiobutton and Label's text variable.

from Tkinter import *

def radio_action():
    value1 = var1.get()
    changeable_label['text'] = value1

the_window = Tk()
the_window.title('Example')

the_window.geometry("200x150")

var1 = StringVar()

changeable_label = Label(the_window, text = "Null")
button1 = Radiobutton(the_window, text = 'Button1', variable = var1,
                     value="Something", command = radio_action)

changeable_label.pack(side = TOP)
button1.pack()


the_window.mainloop()

Since I don't know your whole code, this is I can help with an example.

Post a Comment for "Getting Tkinter Labels To Update When Variable Changes"