Skip to content

Gtk.FontButton

class — extends Widget, Accessible, Buildable, ConstraintTarget, FontChooser

:::warning Deprecated since 4.10 This API is deprecated. :::

The GtkFontButton allows to open a font chooser dialog to change the font.

<picture> <source srcset="font-button-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkFontButton" src="font-button.png"> </picture>

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

CSS nodes

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

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

Constructors

new

@classmethod
def new(cls) -> Widget

:::warning Deprecated since 4.10 This API is deprecated. :::

Creates a new font picker widget.

new_with_font

@classmethod
def new_with_font(cls, fontname: str) -> Widget

:::warning Deprecated since 4.10 This API is deprecated. :::

Creates a new font picker widget showing the given font.

Parameters:

  • fontname — Name of font to display in font chooser dialog

Methods

get_modal

def get_modal(self) -> bool

:::warning Deprecated since 4.10 This API is deprecated. :::

Gets whether the dialog is modal.

get_title

def get_title(self) -> str

:::warning Deprecated since 4.10 This API is deprecated. :::

Retrieves the title of the font chooser dialog.

get_use_font

def get_use_font(self) -> bool

:::warning Deprecated since 4.10 This API is deprecated. :::

Returns whether the selected font is used in the label.

get_use_size

def get_use_size(self) -> bool

:::warning Deprecated since 4.10 This API is deprecated. :::

Returns whether the selected size is used in the label.

set_modal

def set_modal(self, modal: bool) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Sets whether the dialog should be modal.

Parameters:

  • modalTrue to make the dialog modal

set_title

def set_title(self, title: str) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

Sets the title for the font chooser dialog.

Parameters:

  • title — a string containing the font chooser dialog title

set_use_font

def set_use_font(self, use_font: bool) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

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

Parameters:

  • use_font — If True, font name will be written using font chosen.

set_use_size

def set_use_size(self, use_size: bool) -> None

:::warning Deprecated since 4.10 This API is deprecated. :::

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

Parameters:

  • use_size — If True, font name will be written using the selected size.

Properties

modal

modal: bool  # read/write

Whether the font chooser dialog should be modal.

title

title: str  # read/write

The title of the font chooser dialog.

use_font

use_font: bool  # read/write

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

use_size

use_size: bool  # read/write

Whether the buttons label will use the selected font size.

Signals

activate

def on_activate(self) -> None: ...

Emitted to when the font button is activated.

The ::activate signal on GtkFontButton is an action signal and emitting it causes the button to present its dialog.

font-set

def on_font_set(self) -> None: ...

Emitted when the user selects a font.

When handling this signal, use FontChooser.get_font to find out which font was just selected.

Note that this signal is only emitted when the user changes the font. If you need to react to programmatic font changes as well, use the notify::font signal.