Switch

class Switch(**properties: Any)

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Actionable, Buildable, ConstraintTarget

Constructors:

Switch(**properties)
new() -> Gtk.Widget

Constructors

class Switch
classmethod new() Widget

Creates a new GtkSwitch widget.

Methods

class Switch
get_active() bool

Gets whether the GtkSwitch is in its “on” or “off” state.

get_state() bool

Gets the underlying state of the GtkSwitch.

set_active(is_active: bool) None

Changes the state of self to the desired one.

Parameters:

is_activeTrue if self should be active, and False otherwise

set_state(state: bool) None

Sets the underlying state of the GtkSwitch.

This function is typically called from a state_set signal handler in order to set up delayed state changes.

See state_set for details.

Parameters:

state – the new state

Properties

class Switch
props.active: bool

Whether the GtkSwitch widget is in its on or off state.

props.state: bool

The backend state that is controlled by the switch.

Applications should usually set the active property, except when indicating a change to the backend state which occurs separately from the user’s interaction.

See state_set for details.

Signals

class Switch.signals
activate() None

Emitted to animate the switch.

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

state_set(state: bool) bool

Emitted to change the underlying state.

The ::state-set signal is emitted when the user changes the switch position. The default handler calls set_state with the value of state.

To implement delayed state change, applications can connect to this signal, initiate the change of the underlying state, and call set_state when the underlying state change is complete. The signal handler should return True to prevent the default handler from running.

Parameters:

state – the new state of the switch