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
CupertinoSwitchat 1:0.6
- color_toggled = [0.3, 0.85, 0.4, 1]
Background color of
CupertinoSwitchwhen on
Python
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
CupertinoSwitchwhen off
Python
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
CupertinoSwitchis changed- Parameters
instance – Instance of
CupertinoSwitchstate – If
CupertinoSwitchis toggled
- on_touch_move(touch)
Callback when
CupertinoSwitchis dragged- Parameters
touch –
MouseMotionEventdetected onCupertinoSwitch
- switch_duration = 0.1
Duration of color change and thumb movement when state of
CupertinoSwitchis changed
Python
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
CupertinoSwitchin interval [0, 1] as a percentage of theheightofCupertinoSwitch
Python
CupertinoSwitch(thumb_padding=0.1)
KV
CupertinoSwitch: thumb_padding: 0.1
- toggled = False
If
CupertinoSwitchis on
Python
CupertinoSwitch(toggled=True)
KV
CupertinoSwitch: toggled: True