Change the Label by button in tkinter by R4R Team


program-



from tkinter import *
#create a window screen
win=Tk()

def change():
l.config(text='Text has been changed')
l.config(fg='White')
l.config(bg='Green')

#create a label
l=Label(win,text="This is First text on the screen")
l.place(x=100,y=100)

#create a button
b=Button(win,text="Change Text and color",command=change)
b.place(x=100,y=150)

#hold the screen
win.mainloop()


output-




-In this program, we create a Label and the button and at click on the button, change() function is executed and show the following


output-



Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!