O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a font selector

Now that we have seen the basic features that are available in Tkinter's font module, let's implement a font selector like the one shown in the following screenshot:

The key to building the font selector shown in the preceding screenshot is to fetch a list of all the fonts installed on a system. A call to the families() method from the font module fetches a tuple of all the fonts available on a system. Accordingly, when you run the following code, a tuple of all the fonts available on the system gets printed (see the 10.09_all_fonts_on_a_system.py code):

from tkinter import Tk, fontroot = Tk()all_fonts = font.families() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required