Last Updated : 23 Jul, 2025
In Graphical User Interfaces (GUIs), how text is presented holds significant importance for user experience. Tkinter, known as the Primary GUI toolkit for Python, provides powerful capabilities for font management using its Tkinter Fonts module. This module enables developers to tailor the visual aspect of text within their applications, by improving legibility. In this article, we will see about Tkinter Fonts.
What is the Use of Fonts in Tkinter?Fonts in Tkinter are used to customize the appearance of text displayed in various widgets such as labels, buttons, entry widgets, and more. They allow you to control the font family, size, weight, style, and other properties of the text. Here are some common use cases for fonts in Tkinter:
The primary syntax for utilizing Tkinter Fonts is as follows:
import tkinter.font as tkFont
font = tkFont.Font(option, ...)
Here, option
refers to a set of parameters that indicate the characteristics of the font. The available options include:
Below, are the Tkinter Fonts code examples those are as follows.
Creating a Tkinter Window with a Custom FontIn this example, below code creates a Tkinter window and defines a normal Arial font. Then, it displays a label with the text "Normal Text" using the defined font in the window.
Python3
import tkinter as tk
import tkinter.font as tkFont
root = tk.Tk()
# Create fonts with different weights and slants
normal_font = tkFont.Font(family="Arial", size=12, weight=tkFont.NORMAL)
# Create labels using different font styles
label = tk.Label(root, text="Normal Text", font=normal_font)
label.pack()
root.mainloop()
Output
Normal Font Using tkinter.font.NORMAL Creating a Tkinter Window with a Bold Label Using Helvetica FontIn this example, below code creates a Tkinter window with a bold "Hello, Tkinter!" label using the Helvetica font, size 12. It sets up the window, font style, and label, then displays it before entering the main event loop.
Python3
import tkinter as tk
import tkinter.font as tkFont
root = tk.Tk()
font = tkFont.Font(family="Helvetica", size=12, weight="bold")
label = tk.Label(root, text="Hello, Tkinter!", font=font)
label.pack()
root.mainloop()
Output
Bold Font Using tkinter.font.BOLD Styling Text with Italic Fonts in TkinterIn this example, below code sets up a Tkinter window and creates a bold Helvetica font. Then, it displays a label with the text "Hello, Tkinter!" in the window, using the bold font.
Python3
import tkinter as tk
import tkinter.font as tkFont
root = tk.Tk()
font = tkFont.Font(family="Arial", size=10, slant="italic", underline=1)
label = tk.Label(root, text="Styled Text", font=font)
label.pack()
root.mainloop()
Output
Italic Font Using tkinter.font.ITALIC Styling Text with Roman Fonts in TkinterIn this example, below code creates Tkinter window and defines a font in Arial style with a Roman slant. Subsequently, it displays a label in the window with the text "Roman Text" formatted using the defined font.
Python3
import tkinter as tk
import tkinter.font as tkFont
root = tk.Tk()
# Create fonts with different weights and slants
roman_font = tkFont.Font(family="Arial", size=12, slant=tkFont.ROMAN)
# Create labels using font styles
label = tk.Label(root, text="Roman Text", font=roman_font)
label.pack()
root.mainloop()
Output
Roman Font Using tkinter.font.ROMAN Tkinter Window with Resizable Text and Font Size Adjustment ButtonsIn this example, below Python code creates a Tkinter window with a label displaying "Resizable Text" in Times font. It includes buttons to increase and decrease the font size by 2 points each time they're clicked, ensuring the font size doesn't drop below 8 points.
Python3
import tkinter as tk
import tkinter.font as tkFont
def increase_font_size():
font.config(size=font.actual()['size'] + 2)
def decrease_font_size():
font.config(size=max(8, font.actual()['size'] - 2)) # Ensure font size doesn't go below 8
root = tk.Tk()
font = tkFont.Font(family="Times", size=12)
label = tk.Label(root, text="Resizable Text", font=font)
label.pack()
increase_button = tk.Button(root, text="Increase Font Size", command=increase_font_size)
increase_button.pack()
decrease_button = tk.Button(root, text="Decrease Font Size", command=decrease_font_size)
decrease_button.pack()
root.mainloop()
Output
Changing Font Size DynamicallyRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4