O'Reilly logo

Tkinter GUI Programming by Example by David Love

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

Changing the editor's font

As we saw from our blackjack game, fonts in Tkinter are usually handled by a font argument against a widget. The Text widget is no exception, this takes the same argument in the same format—a tuple of (family, size, styles).

To change the font in our text editor, we could decide ourselves what font the editor should be in and hard-code that into the declaration of our TextArea instance. However, we cannot guarantee that the user has that font installed, nor can we assume that they like writing in that font! We also cannot assume what font size the user can read best. The only solution is to allow the user to choose their own font settings and find a way of saving their chosen configuration for the next time they ...

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