Config() in tkinter in python by R4R Team

- config() is a python Tkinter method that are used to change the property of the widget at run time(not at initialization of widget).

Syntax-

widgetobject.config(option=value)

-Here 'option' is may be text, color, font or anything that the property of the widget.


program-

from tkinter import *
#create a window screen
win=Tk()
win.geometry("400x350")

l=Label(win)
l.place(x=100,y=100)

l.config(text="This is the Text")
l.config(fg="white",bg="green")
l.config(font=('arial',23,'bold'))

#hold the screen
win.mainloop()


output-



-In this program, we initially create a window screen by win=Tk() and hold the screen by win.mainloop() in the last.
-then we create a Label, and try to insert or change the property of the Lable by config() method.
-like in config(text="This is the text") method, we put the text in the Label.
-and in config(fg="white",bg="green"), we change the fore-ground colour and back-ground colour of the text.
-by l.config(font=('arial',23,'bold')), we change the font of the text and at last we display that Label by place layout.




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!