Switch
Switches allow users to toggle options
- class kivycupertino.uix.switch.CupertinoSwitch(*args: Any, **kwargs: Any)
iOS style Switch. To comply with iOS standard, keep the width to height ratio of
CupertinoSwitch
at 1:0.6- color_toggled = [0.3, 0.85, 0.4, 1]
Background color of
CupertinoSwitch
when onPython
CupertinoSwitch(color_toggled=(1, 0, 0, 1))
KV
CupertinoSwitch: color_toggled: 1, 0, 0, 1
- color_untoggled = [0.85, 0.85, 0.85, 1]
Background color of
CupertinoSwitch
when offPython
CupertinoSwitch(color_untoggled=(0.5, 0, 0, 1))
KV
CupertinoSwitch: color_untoggled: 0.5, 0, 0, 1
- on_toggled(instance, state)
Callback when state of
CupertinoSwitch
is changed- Parameters
instance – Instance of
CupertinoSwitch
state – If
CupertinoSwitch
is toggled
- on_touch_move(touch)
Callback when
CupertinoSwitch
is dragged- Parameters
touch –
MouseMotionEvent
detected onCupertinoSwitch
- switch_duration = 0.1
Duration of color change and thumb movement when state of
CupertinoSwitch
is changedPython
CupertinoSwitch(switch_duration=0.5)
KV
CupertinoSwitch: switch_duration: 0.5
- thumb_color = [1, 1, 1, 1]
Color of thumb of
CupertinoSwitch
Python
CupertinoSwitch(thumb_color=(1, 0, 0, 1))
KV
CupertinoSwitch: thumb_color: 1, 0, 0, 1
- thumb_padding
Amount of padding around thumb of
CupertinoSwitch
in interval [0, 1] as a percentage of theheight
ofCupertinoSwitch
Python
CupertinoSwitch(thumb_padding=0.1)
KV
CupertinoSwitch: thumb_padding: 0.1
- toggled = False
If
CupertinoSwitch
is onPython
CupertinoSwitch(toggled=True)
KV
CupertinoSwitch: toggled: True