Skip to content

tkinter missing TkDefaultFont #156961

Description

@jvalenzuela

Bug report

Bug description:

Encountering problems looking up TkDefaultFont with Python 3.14.7 on Windows 10(x64), possibly due to the upgrade to Tcl/Tk 9.0.4 that occurred in the 3.14.7 Windows release ref.

The example script below demonstrates the problem:

import tkinter as tk
from tkinter import ttk
import tkinter.font as tkfont

app = tk.Tk()
style = ttk.Style()
font_name = style.lookup("TButton", "font")
font = tkfont.nametofont(font_name)
print(f"{font_name} is {font}")
app.mainloop()

This fails with the following traceback:

Traceback (most recent call last):
  File "C:\Users\jason\Documents\atform\master\font.py", line 8, in <module>
    font = tkfont.nametofont(font_name)
  File "C:\Users\jason\AppData\Local\Programs\Python\Python314\Lib\tkinter\font.py", line 25, in nametofont
    return Font(name=name, exists=True, root=root)
  File "C:\Users\jason\AppData\Local\Programs\Python\Python314\Lib\tkinter\font.py", line 96, in __init__
    raise tkinter._tkinter.TclError(
        "named font %s does not already exist" % (self.name,))
_tkinter.TclError: named font TkDefaultFont does not already exist

This example runs normally on Python versions up to and including 3.14.6, but fails on 3.14.7.

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-tkintertype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions