Skip to content

gh-72880: Add tkinter.fontchooser -- interface to the font selection dialog#153255

Merged
serhiy-storchaka merged 5 commits into
python:mainfrom
serhiy-storchaka:gh-72880-fontchooser
Jul 11, 2026
Merged

gh-72880: Add tkinter.fontchooser -- interface to the font selection dialog#153255
serhiy-storchaka merged 5 commits into
python:mainfrom
serhiy-storchaka:gh-72880-fontchooser

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 7, 2026

Copy link
Copy Markdown
Member

Add the tkinter.fontchooser module, providing the FontChooser class as an interface to the native font selection dialog (the tk fontchooser command, available since Tk 8.6).

The dialog is modal on Windows but modeless on X11 and macOS, so FontChooser mirrors the underlying API instead of forcing a uniform modal behavior: show() may return immediately, and the selected font is delivered to the command callback (as a tkinter.font.Font object) together with the <<TkFontchooserVisibility>> and <<TkFontchooserFontChanged>> virtual events, rather than being returned.

FontChooser(master=None, *, parent=None, title=None, font=None, command=None) supports configure()/config(), cget(), show() and hide(). The options are parent, title, font, command and the read-only visible.

The tests require a GUI; the interactive show()/hide() part runs only on X11.

…ction dialog

The FontChooser class wraps the "tk fontchooser" command.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@read-the-docs-community

read-the-docs-community Bot commented Jul 7, 2026

Copy link
Copy Markdown

serhiy-storchaka and others added 4 commits July 7, 2026 14:07
…ts=0

On macOS the native dialog stores the -font option as a resolved font
description rather than the font name, and with wantobjects=0 Tcl
returns strings instead of integers.  Compare the actual font
attributes and coerce the size to an integer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Take the configuration options via **options and forward them to
configure(), like SysTrayIcon, instead of enumerating each option
in the constructor signature.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) July 11, 2026 05:34
@serhiy-storchaka serhiy-storchaka merged commit b39dfe2 into python:main Jul 11, 2026
51 checks passed
@serhiy-storchaka serhiy-storchaka deleted the gh-72880-fontchooser branch July 11, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant