Table Of Contents
Switch¶
バージョン 1.0.7 で追加.
The Switch
widget is active or inactive, like a mechanical light
switch. The user can swipe to the left/right to activate/deactivate it:
switch = Switch(active=True)
To attach a callback that listens to the activation state:
def callback(instance, value):
print('the switch', instance, 'is', value)
switch = Switch()
switch.bind(active=callback)
By default, the representation of the widget is static. The minimum size required is 83x32 pixels (defined by the background image). The image is centered within the widget.
The entire widget is active, not just the part with graphics. As long as you swipe over the widget’s bounding box, it will work.
注釈
If you want to control the state with a single touch instead of a swipe,
use the ToggleButton
instead.
-
class
kivy.uix.switch.
Switch
(**kwargs)[ソース]¶ ベースクラス:
kivy.uix.widget.Widget
Switch class. See module documentation for more information.
-
active
¶ Indicate whether the switch is active or inactive.
active
is aBooleanProperty
and defaults to False.
-
active_norm_pos
¶ (internal) Contains the normalized position of the movable element inside the switch, in the 0-1 range.
active_norm_pos
is aNumericProperty
and defaults to 0.
-
touch_control
¶ (internal) Contains the touch that currently interacts with the switch.
touch_control
is anObjectProperty
and defaults to None.
-
touch_distance
¶ (internal) Contains the distance between the initial position of the touch and the current position to determine if the swipe is from the left or right.
touch_distance
is aNumericProperty
and defaults to 0.
-