Skip to content

FontDialog

A dialog for selecting and previewing fonts.

This dialog provides a comprehensive interface for selecting fonts, including family, size, weight, slant, and effects (underline, overstrike). The selected font is returned as a tkinter.font.Font object when OK is pressed, or None if canceled.

Attributes:

Name Type Description
result Font | None

The selected font, or None if canceled.

result property

result: Optional[Font]

The selected font, or None if canceled.

__init__

__init__(
    title: str = "font.selector",
    master: Optional[Misc] = None,
    default_font: str = "TkDefaultFont",
)

Create a font selection dialog.

Parameters:

Name Type Description Default
title str

The dialog window title. Will be localized automatically. Defaults to semantic key 'font.selector'.

'font.selector'
master Optional[Misc]

Parent widget. The dialog will be modal and centered on this widget.

None
default_font str

Name of the initial font to display. Can be any valid tkinter font name (e.g., 'TkDefaultFont', 'TkFixedFont', 'TkTextFont', 'TkHeadingFont', etc.) or a custom font name.

'TkDefaultFont'

show

show(**kwargs: Unpack[ShowOptions]) -> None

Show the dialog.