Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[3.15] gh-156961: Fix tkinter.font.Font for a font name returned as a Tcl object (GH-157028) - #157403

Open
serhiy-storchaka wants to merge 1 commit into
python:3.15from
serhiy-storchaka:backport-62cbd34-3.15
Open

[3.15] gh-156961: Fix tkinter.font.Font for a font name returned as a Tcl object (GH-157028)#157403
serhiy-storchaka wants to merge 1 commit into
python:3.15from
serhiy-storchaka:backport-62cbd34-3.15

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Manual backport of GH-157028: the cherry-pick does not apply, because this branch has no wrapped font descriptions (gh-143990), so Font.name is always a string here and __str__ needs a different fix. The test for wrapping a Tcl object as a font description is omitted for the same reason.

Tk can return a font name as a Tcl object rather than a string, for example from ttk.Style().lookup("TButton", "font"), Menu.entrycget("font"), ttk.Entry.cget("font"), or the default value in the result of configure(). Such an object does not compare equal to a string, so it was not recognized as the name of an existing named font, and the code from the issue failed with TclError: named font TkDefaultFont does not already exist.

The object is now kept as is, so that it is passed back to Tk, which reuses the font resource cached in it. It is only converted where it is compared with a string.

…d as a Tcl object (pythonGH-157028)

Tk can return a font name as a Tcl object, for example from
ttk.Style().lookup("TButton", "font"), Menu.entrycget("font"),
ttk.Entry.cget("font"), or the default value in the result of
configure().  Such an object does not compare equal to a string, so it
was not recognized as the name of an existing named font.  Keep it as
is, so that it is passed back to Tk, and only convert it where it is
compared with a string.

(cherry picked from commit 62cbd34)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant