How to list available font families in Tkinter?

Tkinter font property is one of the most valuable properties used to customize a widget's default font. We have already seen many fonts used in widgets, but sometimes it's complicated to determine which fonts are available in the Tkinter library. Python Tkinter is specific about font selection, and we can create an application to list all available fonts.

To use the font library, we need to import it in our environment ?

from tkinter import font

Steps to Create the Font List Application

There are several steps to create this application ?

  • Define a function and create an instance using the font.families() constructor.

  • Iterate over all fonts and display them using Label widgets with specific font styling.

  • Create a canvas with a vertical scrollbar for navigation.

  • Create a frame inside the canvas to display all fonts.

  • Bind mouse events to enable scrolling functionality.

Complete Example

Here's the complete application that displays all available Tkinter fonts ?

# Import required libraries
from tkinter import *
from tkinter import font

# Create an instance of tkinter frame
win = Tk()
win.geometry("750x350")
win.title('Font List')

# Create a list of fonts using the font-family constructor
fonts = list(font.families())
fonts.sort()

def fill_frame(frame):
    for f in fonts:
        # Create a label to display the font
        label = Label(frame, text=f, font=(f, 14)).pack()

def onFrameConfigure(canvas):
    canvas.configure(scrollregion=canvas.bbox("all"))

# Create a canvas
canvas = Canvas(win, bd=1, background="white")

# Create a frame inside the canvas
frame = Frame(canvas, background="white")

# Add a scrollbar
scroll_y = Scrollbar(win, orient="vertical", command=canvas.yview)
canvas.configure(yscrollcommand=scroll_y.set)

scroll_y.pack(side="right", fill="y")
canvas.pack(side="left", expand=1, fill="both")

canvas.create_window((5, 4), window=frame, anchor="n")
frame.bind("<Configure>", lambda e, canvas=canvas: onFrameConfigure(canvas))

fill_frame(frame)
win.mainloop()

How It Works

The application uses font.families() to retrieve all available font families and sorts them alphabetically. Each font is displayed as a Label widget using its own font family for visual representation. The scrollable canvas allows users to navigate through the entire font list.

Output

Executing the above code will display a window that contains a scrollable list of available fonts that Tkinter supports. Each font name is displayed using its own font family, making it easy to preview how each font looks.

Font List Arial Times New Roman Helvetica Courier New Georgia Verdana Comic Sans MS Impact Trebuchet MS Scroll for more fonts...

Conclusion

This application provides a practical way to explore all available Tkinter fonts visually. The scrollable interface makes it easy to browse through the complete font collection and see how each font family renders text.

Updated on: 2026-03-25T19:32:37+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements