Gtk.Switch - Classes - Gtk 3.0 (original) (raw)
g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Actionable Gtk.Actionable GObject.GInterface->Gtk.Actionable Gtk.Activatable Gtk.Activatable GObject.GInterface->Gtk.Activatable Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Switch Gtk.Switch Gtk.Actionable->Gtk.Switch Gtk.Activatable->Gtk.Switch Gtk.Buildable->Gtk.Widget Gtk.Widget->Gtk.Switch
Example¶
Subclasses:
None
Methods¶
Inherited:
Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Actionable (5), Gtk.Activatable (6)
Structs:
Gtk.WidgetClass (12), GObject.ObjectClass (5)
class | new () |
---|---|
get_active () | |
get_state () | |
set_active (is_active) | |
set_state (state) |
Virtual Methods¶
Inherited:
Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gtk.Actionable (4), Gtk.Activatable (2)
do_activate () |
---|
do_state_set (state) |
Properties¶
Inherited:
Gtk.Widget (39), Gtk.Actionable (2), Gtk.Activatable (2)
Name | Type | Flags | Short Description |
---|---|---|---|
active | bool | r/w/en | Whether the switch is on or off |
state | bool | r/w/en | The backend state |
Style Properties¶
Inherited:
Name | Type | Default | Flags | Short Description |
---|---|---|---|---|
slider-height | int | 22 | d/r | The minimum height of the handle deprecated |
slider-width | int | 36 | d/r | The minimum width of the handle deprecated |
Signals¶
Inherited:
Gtk.Widget (69), GObject.Object (1)
Name | Short Description |
---|---|
activate | The ::activate signal on Gtk.Switch is an action signal and emitting it causes the switch to animate. |
state-set | The ::state-set signal on Gtk.Switch is emitted to change the underlying state. |
Fields¶
Inherited:
Gtk.Widget (69), GObject.Object (1)
Name | Type | Access | Description |
---|---|---|---|
parent_instance | Gtk.Widget | r |
Class Details¶
class Gtk.Switch(**kwargs)¶
Bases:
Gtk.Widget, Gtk.Actionable, Gtk.Activatable
Abstract:
No
Structure:
Gtk.Switch is a widget that has two states: on or off. The user can control which state should be active by clicking the empty area, or by dragging the handle.
Gtk.Switch can also handle situations where the underlying state changes with a delay. See Gtk.Switch ::state-set for details.
CSS nodes
Gtk.Switch has two css nodes, the main node with the name switch and a subnode named slider. Neither of them is using any style classes.
Returns:
the newly created Gtk.Switch instance
Return type:
Creates a new Gtk.Switch widget.
New in version 3.0.
Returns:
True if the Gtk.Switch is active, and False otherwise
Return type:
Gets whether the Gtk.Switch is in its “on” or “off” state.
New in version 3.0.
Returns:
the underlying state
Return type:
Gets the underlying state of the Gtk.Switch.
New in version 3.14.
set_active(is_active)[source]¶
Parameters:
is_active (bool) – True if self should be active, and False otherwise
Changes the state of self to the desired one.
New in version 3.0.
Parameters:
state (bool) – the new state
Sets the underlying state of the Gtk.Switch.
Normally, this is the same as Gtk.Switch :active, unless the switch is set up for delayed state changes. This function is typically called from a Gtk.Switch ::state-set signal handler.
See Gtk.Switch ::state-set for details.
New in version 3.14.
do_activate() virtual¶
An action signal and emitting it causes the switch to animate.
do_state_set(state) virtual¶
Parameters:
state (bool) –
Return type:
Class handler for the ::state-set signal.
Signal Details¶
Gtk.Switch.signals.activate(switch)¶
Signal Name:
activate
Flags:
Parameters:
switch (Gtk.Switch) – The object which received the signal
The ::activate signal on Gtk.Switch is an action signal and emitting it causes the switch to animate. Applications should never connect to this signal, but use the notify::active signal.
Gtk.Switch.signals.state_set(switch, state)¶
Signal Name:
state-set
Flags:
Parameters:
- switch (Gtk.Switch) – The object which received the signal
- state (bool) – the new state of the switch
Returns:
True to stop the signal emission
Return type:
The ::state-set signal on Gtk.Switch is emitted to change the underlying state. It is emitted when the user changes the switch position. The default handler keeps the state in sync with the Gtk.Switch :activeproperty.
To implement delayed state change, applications can connect to this signal, initiate the change of the underlying state, and call Gtk.Switch.set_state() when the underlying state change is complete. The signal handler should return True to prevent the default handler from running.
Visually, the underlying state is represented by the trough color of the switch, while the Gtk.Switch :active property is represented by the position of the switch.
New in version 3.14.
Property Details¶
Gtk.Switch.props.active¶
Name:
active
Type:
Default Value:
Flags:
READABLE, WRITABLE, EXPLICIT_NOTIFY
Whether the Gtk.Switch widget is in its on or off state.
Gtk.Switch.props.state¶
Name:
state
Type:
Default Value:
Flags:
READABLE, WRITABLE, EXPLICIT_NOTIFY
The backend state that is controlled by the switch. See Gtk.Switch ::state-set for details.
New in version 3.14.