[issue35728] Tkinter font nametofont requires default root
Terry J. Reedy
report at bugs.python.org
Sat Jan 12 16:33:33 EST 2019
New submission from Terry J. Reedy <tjreedy at udel.edu>:
font.Font.__init__, font.families, and font.names have a 'root=None' argument and start with
if not root:
root = tkinter._default_root
But font.nametofont does not, and so it calls Font without passing a root argument:
return Font(name=name, exists=True)
Font fails if there is no default root. There cannot be one if, as recommended, one disables it.
import tkinter as tk
from tkinter import font
tk.NoDefaultRoot()
root = tk.Tk()
font.nametofont('TkFixedFont')
# AttributeError: module 'tkinter' has no attribute '_default_root'
Proposed fix: add 'root=None' parameter to nametofont (at end, to not break code) and 'root=root' to Font call.
----------
components: Tkinter
messages: 333532
nosy: serhiy.storchaka, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: Tkinter font nametofont requires default root
type: behavior
versions: Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35728>
_______________________________________
More information about the Python-bugs-list
mailing list