Answers for "how to update a label tkinter"

3

tkinter change label text

pythonCopyimport tkinter as tk

class Test():
    def __init__(self):
        self.root = tk.Tk()
        self.text = tk.StringVar()
        self.text.set("Test")
        self.label = tk.Label(self.root, textvariable=self.text)

        self.button = tk.Button(self.root,
                                text="Click to change text below",
                                command=self.changeText)
        self.button.pack()
        self.label.pack()
        self.root.mainloop()

    def changeText(self):
        self.text.set("Text updated")        

app=Test()
Posted by: Guest on December-26-2020
1

label change in tkinter

stud_input=StringVar()
stud_input.set("Label")
lbl3=Label(add_image_frame,textvariable=stud_input,bg="#ED6244",fg="black").grid(row=4,column=0)
stud_input.set("Changed Label")
Posted by: Guest on October-12-2020
0

how to update values in tkinter

import tkinter as tk

win = tk.Tk()
max_amount = 0
label1 = None #just so it is defined

def fun():
    global max_amount, label1
    max_amount +=100
    label1.configure(text='Balance :$' + str(max_amount))

btn = tk.Button(win,text = 'Change', command = fun)
btn.grid()
t1 =str(max_amount)
label1 = tk.Label(win,text = 'Balance :$' + t1)
label1.grid()

win.mainloop()
Posted by: Guest on October-26-2020

Python Answers by Framework

Browse Popular Code Answers by Language