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

../_images/demo16.gif
color_toggled = [0.3, 0.85, 0.4, 1]

Background color of CupertinoSwitch when on

../_images/color_toggled.gif

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 CupertinoSwitch when off

../_images/color_untoggled.gif

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 CupertinoSwitch is changed

Parameters
on_touch_move(touch)

Callback when CupertinoSwitch is dragged

Parameters

touchMouseMotionEvent detected on CupertinoSwitch

switch_duration = 0.1

Duration of color change and thumb movement when state of CupertinoSwitch is changed

../_images/switch_duration.gif

Python

CupertinoSwitch(switch_duration=0.5)

KV

CupertinoSwitch:
    switch_duration: 0.5
thumb_color = [1, 1, 1, 1]

Color of thumb of CupertinoSwitch

../_images/thumb_color.gif

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 the height of CupertinoSwitch

../_images/thumb_padding.gif

Python

CupertinoSwitch(thumb_padding=0.1)

KV

CupertinoSwitch:
    thumb_padding: 0.1
toggled = False

If CupertinoSwitch is on

../_images/toggled.png

Python

CupertinoSwitch(toggled=True)

KV

CupertinoSwitch:
    toggled: True