CheckButton

class CheckButton(**properties: Any)

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Actionable, Buildable, ConstraintTarget

Constructors:

CheckButton(**properties)
new() -> Gtk.Widget
new_with_label(label:str=None) -> Gtk.Widget
new_with_mnemonic(label:str=None) -> Gtk.Widget

Constructors

class CheckButton
classmethod new() Widget

Creates a new GtkCheckButton.

classmethod new_with_label(label: str | None = None) Widget

Creates a new GtkCheckButton with the given text.

Parameters:

label – the text for the check button.

classmethod new_with_mnemonic(label: str | None = None) Widget

Creates a new GtkCheckButton with the given text and a mnemonic.

Parameters:

label – The text of the button, with an underscore in front of the mnemonic character

Methods

class CheckButton
get_active() bool

Returns whether the check button is active.

get_child() Widget | None

Gets the child widget of button or NULL if label is set.

Added in version 4.8.

get_inconsistent() bool

Returns whether the check button is in an inconsistent state.

get_label() str | None

Returns the label of the check button or NULL if child is set.

get_use_underline() bool

Returns whether underlines in the label indicate mnemonics.

set_active(setting: bool) None

Changes the check buttons active state.

Parameters:

setting – the new value to set

set_child(child: Widget | None = None) None

Sets the child widget of button.

Note that by using this API, you take full responsibility for setting up the proper accessibility label and description information for button. Most likely, you’ll either set the accessibility label or description for button explicitly, or you’ll set a labelled-by or described-by relations from child to button.

Added in version 4.8.

Parameters:

child – the child widget

set_group(group: CheckButton | None = None) None

Adds self to the group of group.

In a group of multiple check buttons, only one button can be active at a time. The behavior of a checkbutton in a group is also commonly known as a radio button.

Setting the group of a check button also changes the css name of the indicator widget’s CSS node to ‘radio’.

Setting up groups in a cycle leads to undefined behavior.

Note that the same effect can be achieved via the Actionable API, by using the same action with parameter type and state type ‘s’ for all buttons in the group, and giving each button its own target value.

Parameters:

group – another GtkCheckButton to form a group with

set_inconsistent(inconsistent: bool) None

Sets the GtkCheckButton to inconsistent state.

You should turn off the inconsistent state again if the user checks the check button. This has to be done manually.

Parameters:

inconsistentTrue if state is inconsistent

set_label(label: str | None = None) None

Sets the text of self.

If use_underline is True, an underscore in label is interpreted as mnemonic indicator, see set_use_underline for details on this behavior.

Parameters:

label – The text shown next to the indicator, or None to show no text

set_use_underline(setting: bool) None

Sets whether underlines in the label indicate mnemonics.

If setting is True, an underscore character in self’s label indicates a mnemonic accelerator key. This behavior is similar to use_underline.

Parameters:

setting – the new value to set

Properties

class CheckButton
props.active: bool

If the check button is active.

Setting active to True will add the :checked: state to both the check button and the indicator CSS node.

props.child: Widget

The child widget.

Added in version 4.8.

props.group: CheckButton

The check button whose group this widget belongs to.

props.inconsistent: bool

If the check button is in an “in between” state.

The inconsistent state only affects visual appearance, not the semantics of the button.

props.label: str

Text of the label inside the check button, if it contains a label widget.

props.use_underline: bool

If set, an underline in the text indicates that the following character is to be used as mnemonic.

Signals

class CheckButton.signals
activate() None

Emitted to when the check button is activated.

The ::activate signal on GtkCheckButton is an action signal and emitting it causes the button to animate press then release.

Applications should never connect to this signal, but use the toggled signal.

The default bindings for this signal are all forms of the <kbd>␣</kbd> and Enter keys.

Added in version 4.2.

toggled() None

Emitted when the buttons’s active property changes.

Virtual Methods

class CheckButton
do_activate() None
do_toggled() None

Fields

class CheckButton
parent_instance