How to increase the font size of a Text widget?


We can customize the Tkinter widget by modifying the value of its properties such as font-family, text-size, text-size, width, the height of the frame, etc. Tkinter Text widgets are generally used for accepting multiline user input. It is similar to a standard text widget.

To configure the text properties of the a widget, we can use the font(‘font-family font-size font-style) attribute by defining its font-family, font-size, and the font style.

Example

#Import tkinter library
from tkinter import *
#Create an instance of Tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
win.geometry("750x250")
#Create a Text widget
text= Text(win, width= 60, height= 10, font=('Century Schoolbook', 20, 'italic'))
text.insert(INSERT, "Hello\nWelcome to TutorialsPoint.com!")
text.pack()
win.mainloop()

Output

Executing the above code will display a text editor which has the customized font attributes.

Now, change the font attributes properties to see the reflected changes.

Updated on: 22-Apr-2021

531 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements