Python Tkinter Label is a Tkinter widget class that is used to display text or image in the parent widget. Tkinter widget is non-interactive widget whose Main purpose is to display any message to the user.
Here We Can see that How to change the tkinter label text.
Example:
from tkinter import *
window = Tk()
window.title("Change Label Text")
window.geometry("800x350+450+86")
window.config(bg="#800000")
var_2=StringVar()
label1 = Label(window, font=("helvetica", 20,"bold"),borderwidth=20)
label2 = Label(window, font=("helvetica", 20,"bold"),borderwidth=20, textvariable=var_2)
label1.pack(pady=15)
label2.pack(pady=20)
label1["text"]="This is First Label" # set text to Lable1
var_2.set("I Am Second Label") # set text to Lable2 using variable (var_2)
window.mainloop()
Post a Comment