Skip to Content
Python GUI Programming with Tkinter
book

Python GUI Programming with Tkinter

by Alan D. Moore
May 2018
Beginner to intermediate content levelBeginner to intermediate
452 pages
11h 26m
English
Packt Publishing
Content preview from Python GUI Programming with Tkinter

Tkinter fonts

There are three ways of specifying a widget's font in Tkinter.

The simplest way is to just use a string format:

tk.Label(text="Direct font format",          font="Times 20 italic bold")

The string takes the format Font-family size styles, where styles can be any valid combination of text style keywords.

Those words include:

  • bold for boldface text, or normal for normal weight
  • italic for italized text, or roman for regular slant
  • underline for underlined text
  • overstrike for struck-out text

Everything but the font family is optional, though you need to specify a size if you want to specify any of the styling keywords. The ordering of style keywords doesn't matter, but the weight and slant keywords are mutually exclusive (that is, you ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python GUI Programming with Tkinter - Second Edition

Python GUI Programming with Tkinter - Second Edition

Alan D. Moore

Publisher Resources

ISBN: 9781788835886Supplemental Content