FontDialogButton

Added in version 4.10.

class FontDialogButton(**properties: Any)

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ConstraintTarget

The GtkFontDialogButton is wrapped around a FontDialog and allows to open a font chooser dialog to change the font.

https://docs.gtk.org/gtk4/font-button.png

It is suitable widget for selecting a font in a preference dialog.

CSS nodes

fontbutton
╰── button.font
    ╰── [content]

GtkFontDialogButton has a single CSS node with name fontbutton which contains a button node with the .font style class.

Constructors

class FontDialogButton
classmethod new(dialog: FontDialog | None = None) Widget

Creates a new GtkFontDialogButton with the given GtkFontDialog.

You can pass NULL to this function and set a GtkFontDialog later. The button will be insensitive until that happens.

Added in version 4.10.

Parameters:

dialog – the GtkFontDialog to use

Methods

class FontDialogButton
get_dialog() FontDialog | None

Returns the GtkFontDialog of self.

Added in version 4.10.

get_font_desc() FontDescription | None

Returns the font of the button.

This function is what should be used to obtain the font that was chosen by the user. To get informed about changes, listen to “notify::font-desc”.

Added in version 4.10.

get_font_features() str | None

Returns the font features of the button.

This function is what should be used to obtain the font features that were chosen by the user. To get informed about changes, listen to “notify::font-features”.

Note that the button will only let users choose font features if level is set to GTK_FONT_LEVEL_FEATURES.

Added in version 4.10.

get_language() Language | None

Returns the language that is used for font features.

Added in version 4.10.

get_level() FontLevel

Returns the level of detail at which this dialog lets the user select fonts.

Added in version 4.10.

get_use_font() bool

Returns whether the selected font is used in the label.

Added in version 4.10.

get_use_size() bool

Returns whether the selected font size is used in the label.

Added in version 4.10.

set_dialog(dialog: FontDialog) None

Sets a GtkFontDialog object to use for creating the font chooser dialog that is presented when the user clicks the button.

Added in version 4.10.

Parameters:

dialog – the new GtkFontDialog

set_font_desc(font_desc: FontDescription) None

Sets the font of the button.

Added in version 4.10.

Parameters:

font_desc – the new font

set_font_features(font_features: str | None = None) None

Sets the font features of the button.

Added in version 4.10.

Parameters:

font_features – the font features

set_language(language: Language | None = None) None

Sets the language to use for font features.

Added in version 4.10.

Parameters:

language – the new language

set_level(level: FontLevel) None

Sets the level of detail at which this dialog lets the user select fonts.

Added in version 4.10.

Parameters:

level – the level of detail

set_use_font(use_font: bool) None

If use_font is TRUE, the font name will be written using the selected font.

Added in version 4.10.

Parameters:

use_font – If TRUE, font name will be written using the chosen font

set_use_size(use_size: bool) None

If use_size is TRUE, the font name will be written using the selected font size.

Added in version 4.10.

Parameters:

use_size – If TRUE, font name will be written using the chosen font size

Properties

class FontDialogButton
props.dialog: FontDialog

The GtkFontDialog that contains parameters for the font chooser dialog.

Added in version 4.10.

props.font_desc: FontDescription

The selected font.

This property can be set to give the button its initial font, and it will be updated to reflect the users choice in the font chooser dialog.

Listen to notify::font-desc to get informed about changes to the buttons font.

Added in version 4.10.

props.font_features: str

The selected font features.

This property will be updated to reflect the users choice in the font chooser dialog.

Listen to notify::font-features to get informed about changes to the buttons font features.

Added in version 4.10.

props.language: Language

The selected language for font features.

This property will be updated to reflect the users choice in the font chooser dialog.

Listen to notify::language to get informed about changes to the buttons language.

Added in version 4.10.

props.level: FontLevel

The level of detail for the font chooser dialog.

props.use_font: bool

Whether the buttons label will be drawn in the selected font.

props.use_size: bool

Whether the buttons label will use the selected font size.

Signals

class FontDialogButton.signals
activate() None

Emitted when the font dialog button is activated.

The ::activate signal on GtkFontDialogButton is an action signal and emitting it causes the button to pop up its dialog.

Added in version 4.14.