Finer control over font

In addition to the aforementioned method of handling fonts, Tkinter provides a separate Font class implementation. The source code for this class is located in the same folder as the source code for Tkinter.

On my Linux machine, the source code is located in /usr/local/lib/python3.6/tkinter/font.py. On Windows (with a default Python 3.6 install) the location is C:\Program Files (x86)\Python36-32\Lib\tkinter\font.py.

To use this module, you need to import fonts into your namespace, as follows (see the 10.08_font_demo.py code):

from tkinter import Tk, Label, Packfrom tkinter import fontroot = Tk()label = Label(root, text="Humpty Dumpty was pushed")label.pack()current_font = font.Font(font=label['font'])print ('Actual ...

Get Tkinter GUI Application Development Blueprints - Second Edition 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.