Skip to content

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

Open
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:gh-72880-fontchooser
Open

gh-72880: Add tkinter.fontchooser -- interface to the font selection dialog#153255
serhiy-storchaka wants to merge 2 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

Documentation build overview

📚 cpython-previews | 🛠️ Build #33476803 | 📁 Comparing 58240c4 against main (2cd5b79)

  🔍 Preview build  

7 files changed · + 1 added · ± 6 modified

+ Added

± Modified

…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>
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