font() in tkinter in python by R4R Team

- font() is a python tkinter method that are used to change the shape of the text of the widget.
- Generally it is used with Labels and Buttons.

Syntax-

font(style,size,option=value)

-Here style like arial, times new roman, courier etc.
-size is Numeric value that change the size of the text
-Other option may be bold text or not.


program-

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

l=Label(win,text="first Text",font=('courier',40,'bold'))
l.place(x=50,y=50)

l=Label(win,text="second Text",font=('Times New Roman',20,'bold'),fg="red")
l.place(x=100,y=100)

l=Label(win,text="Third Text",font=('arial',30,'bold'),fg="blue")
l.place(x=150,y=200)

#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 different Lable text with different font property.




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!