beetlebug▾
/

tk fontchooser

Shows the font dialog of the platform, and keeps its options.

tk fontchooser configure ?-option ?VALUE ...??
tk fontchooser show
tk fontchooser hide

Description

configure gives or sets the options -parent, -title, -font, and -command, and gives -visible, 1 while the dialog shows. With no option it gives each option and its value.

On Windows and macOS, show runs the font dialog of the platform to its end, with -font as the first choice. A chosen font goes in -font, the script of -command runs with the font appended, and -parent gets the virtual event <<TkFontchooserFontChanged>>. The parent gets <<TkFontchooserVisibility>> when the dialog opens and closes.

The other backends, also the headless backend and the web build, have no font dialog: show sets -visible to 1 and sends <<TkFontchooserVisibility>>, and hide sets it to 0.

Returns

The options, a value, or an empty string.

Examples

% tk fontchooser configure -title "Text font"
> tk fontchooser configure -title
Text font

# The headless backend has no font dialog, so `show` only sets `-visible`.
% tk fontchooser show
> tk fontchooser configure -visible
1

Errors

% tk fontchooser configure -size 12
bad option "-size": must be -command, -font, -parent, or -title
-errorcode NONE

% tk fontchooser open
unknown or ambiguous subcommand "open": must be configure, hide, or show
-errorcode NONE

Differences from Tcl

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1