bootstack.dialogs.FontDialog#

class bootstack.dialogs.FontDialog(*, title='', default_font='body', parent=None)#

Bases: object

A dialog for selecting a font family, size, weight, slant, and effects.

The dialog shows a scrollable list of font families, a size list, and controls for weight (normal/bold), slant (roman/italic), underline, and overstrike. A live preview panel shows sample text rendered in the selected font.

Parameters:
  • title (str) – Dialog window title. Defaults to the localized “Font” string.

  • default_font (str) – Font token to show initially (e.g. 'body', 'code', 'heading-lg'). Defaults to 'body'. See Typography.

  • parent (Any) – Parent widget. Defaults to the active root window.

property result: FontChoice | None#

The selected font, or None if canceled.

Returns a FontChoice namedtuple with six attributes:

  • family — font family name (str).

  • size — point size (int).

  • weight'normal' or 'bold'.

  • slant'roman' or 'italic'.

  • underlineTrue if underlined.

  • overstrikeTrue if struck through.

show(*, position=None, modal=None)#

Display the dialog and block until it is closed.

Parameters:
  • position (tuple[int, int] | None) – Explicit (x, y) screen coordinates for the dialog. Defaults to centered on screen (the font dialog sizes itself on open).

  • modal (bool | None) – Override the default modality. True blocks the parent; False shows a non-blocking dialog.

Returns:

self — allows chaining – dlg = FontDialog(...).show(); dlg.result.

Return type:

FontDialog