pythontkinter

List available font families in `tkinter`


In many tkinter examples available out there, you may see things like:

canvas.create_text(x, y, font=('Helvetica', 12), text='foo')

However, this may not work when run in your computer (the result would completely ignore the font parameter). Aparently, the font parameter is ignored if there is any incorrect value in it.

In order to check if the font family is valid, how can I list all available in my system?


Solution

  • from tkinter import Tk, font
    root = Tk()
    font.families()