Gtk.Switch¶
Example¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Actionable (5), Gtk.Activatable (6)
- Structs:
class |
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gtk.Actionable (4), Gtk.Activatable (2)
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
Whether the switch is on or off |
||
r/w/en |
The backend state |
Style Properties¶
- Inherited:
Name |
Type |
Default |
Flags |
Short Description |
---|---|---|---|---|
|
|
d/r |
The minimum height of the handle |
|
|
|
d/r |
The minimum width of the handle |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
The |
|
The |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gtk.Switch(**kwargs)¶
- Bases:
- 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. SeeGtk.Switch
::state-set
for details.- CSS nodes
switch ╰── slider
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.- classmethod new()[source]¶
- Returns:
the newly created
Gtk.Switch
instance- Return type:
Creates a new
Gtk.Switch
widget.New in version 3.0.
- get_active()[source]¶
- Returns:
True
if theGtk.Switch
is active, andFalse
otherwise- Return type:
Gets whether the
Gtk.Switch
is in its “on” or “off” state.New in version 3.0.
- get_state()[source]¶
- Returns:
the underlying state
- Return type:
Gets the underlying state of the
Gtk.Switch
.New in version 3.14.
- set_state(state)[source]¶
- 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 aGtk.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¶
-
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 onGtk.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 signalstate (
bool
) – the new state of the switch
- Returns:
True
to stop the signal emission- Return type:
The
::state-set
signal onGtk.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 theGtk.Switch
:active
property.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 returnTrue
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:
Whether the
Gtk.Switch
widget is in its on or off state.
- Gtk.Switch.props.state¶
- Name:
state
- Type:
- Default Value:
- Flags:
The backend state that is controlled by the switch. See
Gtk.Switch
::state-set
for details.New in version 3.14.