Gtk.Switch¶
Example¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Actionable (5)
- Structs:
class |
|
|
|
|
|
|
|
|
Virtual Methods¶
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r/w/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted to animate the switch. |
|
Emitted to change the underlying state. |
Fields¶
- Inherited:
Class Details¶
- class Gtk.Switch(**kwargs)¶
- Bases:
- Abstract:
No
GtkSwitch
is a “light switch” that has two states: on or off.An example
Gtk.Switch
The user can control which state should be active by clicking the empty area, or by dragging the handle.
GtkSwitch
can also handle situations where the underlying state changes with a delay. In this case, the slider position indicates the user’s recent change (as indicated by the [property`Gtk`.Switch:active] property), and the color indicates whether the underlying state (represented by the [property`Gtk`.Switch:state] property) has been updated yet.Gtk.Switch
with delayed state changeSee [signal`Gtk`.Switch::state-set] for details.
- CSS nodes
`` switch ├── image ├── image ╰── slider ``
GtkSwitch
has four css nodes, the main node with the name switch and subnodes for the slider and the on and off images. Neither of them is using any style classes.- Accessibility
GtkSwitch
uses theGtk.AccessibleRole.SWITCH
role.- classmethod new()[source]¶
- Returns:
the newly created
GtkSwitch
instance- Return type:
Creates a new
GtkSwitch
widget.
- get_state()[source]¶
- Returns:
the underlying state
- Return type:
Gets the underlying state of the
GtkSwitch
.
Signal Details¶
- Gtk.Switch.signals.activate(switch)¶
- Signal Name:
activate
- Flags:
- Parameters:
switch (
Gtk.Switch
) – The object which received the signal
Emitted to animate the switch.
Applications should never connect to this signal, but use the [property`Gtk`.Switch:active] property.
- 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:
Emitted to change the underlying state.
The
::state-set
signal is emitted when the user changes the switch position. The default handler keeps the state in sync with the [property`Gtk`.Switch:active] property.To implement delayed state change, applications can connect to this signal, initiate the change of the underlying state, and call [method`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 [property`Gtk`.Switch:active] property is represented by the position of the switch.
Property Details¶
- Gtk.Switch.props.active¶
- Name:
active
- Type:
- Default Value:
- Flags:
Whether the
GtkSwitch
widget is in its on or off state.