gtk.check_button

Module for [CheckButton] class

Types 3

A [gtk.check_button.CheckButton] places a label next to an indicator.

!Example GtkCheckButtons

A [gtk.check_button.CheckButton] is created by calling either [gtk.check_button.CheckButton.new_] or [gtk.check_button.CheckButton.newWithLabel].

The state of a [gtk.check_button.CheckButton] can be set specifically using [gtk.check_button.CheckButton.setActive], and retrieved using [gtk.check_button.CheckButton.getActive].

Inconsistent state

In addition to "on" and "off", check buttons can be an "in between" state that is neither on nor off. This can be used e.g. when the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a check button, and the current values in that range are inconsistent.

To set a [gtk.check_button.CheckButton] to inconsistent state, use [gtk.check_button.CheckButton.setInconsistent].

Grouping

Check buttons can be grouped together, to form mutually exclusive groups - only one of the buttons can be toggled at a time, and toggling another one will switch the currently toggled one off.

Grouped check buttons use a different indicator, and are commonly referred to as radio buttons.

!Example GtkCheckButtons

To add a [gtk.check_button.CheckButton] to a group, use [gtk.check_button.CheckButton.setGroup].

When the code must keep track of the state of a group of radio buttons, it is recommended to keep track of such state through a stateful [gio.action.Action] with a target for each button. Using the toggled signals to keep track of the group changes and state is discouraged.

CSS nodes

checkbutton[.text-button]
├── check
╰── [label]

A [gtk.check_button.CheckButton] has a main node with name checkbutton. If the [gtk.check_button.CheckButton.label] or [gtk.check_button.CheckButton.child] properties are set, it contains a child widget. The indicator node is named check when no group is set, and radio if the checkbutton is grouped together with other checkbuttons.

Accessibility

[gtk.check_button.CheckButton] uses the [gtk.types.AccessibleRole.Checkbox] role.

Methods
GType _gType() @property
CheckButton self()Returns `this`, for use in `with` statements.
CheckButtonGidBuilder builder()Get builder for [gtk.check_button.CheckButton] Returns: New builder object
bool active() @propertyGet `active` property. Returns: If the check button is active.
void active(bool propval) @propertySet `active` property. Params: propval = If the check button is active.
gtk.widget.Widget child() @propertyGet `child` property. Returns: The child widget.
void child(gtk.widget.Widget propval) @propertySet `child` property. Params: propval = The child widget.
void group(gtk.check_button.CheckButton propval) @propertySet `group` property. Params: propval = The check button whose group this widget belongs to.
bool inconsistent() @propertyGet `inconsistent` property. Returns: If the check button is in an “in between” state.
void inconsistent(bool propval) @propertySet `inconsistent` property. Params: propval = If the check button is in an “in between” state.
string label() @propertyGet `label` property. Returns: Text of the label inside the check button, if it contains a label widget.
void label(string propval) @propertySet `label` property. Params: propval = Text of the label inside the check button, if it contains a label widget.
bool useUnderline() @propertyGet `useUnderline` property. Returns: If set, an underline in the text indicates that the following character is to be used as mnemonic.
void useUnderline(bool propval) @propertySet `useUnderline` property. Params: propval = If set, an underline in the text indicates that the following character is to be used as mnemonic.
gtk.check_button.CheckButton newWithLabel(string label = null)Creates a new [gtk.check_button.CheckButton] with the given text.
gtk.check_button.CheckButton newWithMnemonic(string label = null)Creates a new [gtk.check_button.CheckButton] with the given text and a mnemonic.
bool getActive()Returns whether the check button is active. Returns: whether the check button is active
gtk.widget.Widget getChild()Gets the child widget of button or `NULL` if `propertyCheckButton:label` is set. Returns: the child widget of button
bool getInconsistent()Returns whether the check button is in an inconsistent state. Returns: true if check_button is currently in an inconsistent state
string getLabel()Returns the label of the check button or `NULL` if `propertyCheckButton:child` is set. Returns: The label self shows next to the indicator. If no label is shown, null will be returned.
bool getUseUnderline()Returns whether underlines in the label indicate mnemonics. Returns: The value of the `propertyGtk.CheckButton:use-underline` property. See [gtk.check_button.CheckButton.setUseUnderline] for detail...
void setActive(bool setting)Changes the check buttons active state.
void setChild(gtk.widget.Widget child = null)Sets the child widget of button.
void setGroup(gtk.check_button.CheckButton group = null)Adds self to the group of group.
void setInconsistent(bool inconsistent)Sets the [gtk.check_button.CheckButton] to inconsistent state.
void setLabel(string label = null)Sets the text of self.
void setUseUnderline(bool setting)Sets whether underlines in the label indicate mnemonics.
gulong connectActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.check_button.CheckButton))) && Parameters!T.length < 2)Connect to `Activate` signal.
gulong connectToggled(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.check_button.CheckButton))) && Parameters!T.length < 2)Connect to `Toggled` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.checkbutton.CheckButton]. Returns: a new [gtk.checkbutton.CheckButton]
Methods
T active(bool propval)Set `active` property. Params: propval = If the check button is active.
T child(gtk.widget.Widget propval)Set `child` property. Params: propval = The child widget. Returns: Builder instance for fluent chaining
T group(gtk.check_button.CheckButton propval)Set `group` property. Params: propval = The check button whose group this widget belongs to. Returns: Builder instance for fluent chaining
T inconsistent(bool propval)Set `inconsistent` property. Params: propval = If the check button is in an “in between” state.
T label(string propval)Set `label` property. Params: propval = Text of the label inside the check button, if it contains a label widget. Returns: Builder instance for fluent chaining
T useUnderline(bool propval)Set `useUnderline` property. Params: propval = If set, an underline in the text indicates that the following character is to be used as mnemonic. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.check_button.CheckButton]