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 ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.