Behavior

Behaviors allow for expanded functionality for existing widgets

Note

Behaviors can only be used as superclasses for instances of Widget

class kivycupertino.uix.behavior.CupertinoButtonBehavior(*args: Any, **kwargs: Any)

Base class for buttons that can only be used with an instance of kivy.uix.widget.Widget

color

Current color of a widget with CupertinoButtonBehavior

color_disabled

Color of widget with CupertinoButtonBehavior when disabled

../_images/color_disabled.png

Python

CupertinoButton(disabled=True, color_disabled=(0.5, 0, 0, 1))

KV

CupertinoButton:
    disabled: True
    color_disabled: 0.5, 0, 0, 1
color_down

Color of widget with CupertinoButtonBehavior when pressed

../_images/color_down.gif

Python

CupertinoButton(color_down=(1, 0, 0, 1))

KV

CupertinoButton:
    color_down: 1, 0, 0, 1
color_normal

Color of widget with CupertinoButtonBehavior when not pressed or disabled

../_images/color_normal.png

Python

CupertinoButton(color_normal=(1, 0, 0, 1))

KV

CupertinoButton:
    color_normal: 1, 0, 0, 1
disabled

If widget with CupertinoButtonBehavior is disabled

../_images/disabled.png

Python

CupertinoButton(disabled=True)

KV

CupertinoButton:
    disabled: True
transition_duration = 0.075

Duration of the transition of the color of widget with CupertinoButtonBehavior when its state changes

../_images/transition_duration.gif

Python

CupertinoButton(transition_duration=0.5)

KV

CupertinoButton:
    transition_duration: 0.5
class kivycupertino.uix.behavior.LongPressBehavior(**kwargs)

Behavior to detect a long press on a widget

../_images/demo1.gif
long_press_duration = 1

Time that constitutes a long press

../_images/long_press_duration.gif

Python

ExampleWidget(long_press_duration=2)

KV

ExampleWidget:
    long_press_duration: 2
on_long_press(touch)

Event when a widget is long pressed

Parameters

touch – The touch on this widget

class kivycupertino.uix.behavior.SelectableBehavior(**kwargs)

Behavior to detect a selection of a specific widget among all other widgets in parent

../_images/demo2.gif
on_chosen()

Event when a widget is selected

on_selected(instance, value)

Callback when selected of a widget with SelectableBehavior is changed

Parameters
refresh()

Set selected of this instance of SelectableBehavior to True while setting all other instances in parent to False

Note

This function is mainly to be used when adding widgets to a parent. Otherwise, setting selected to True will achieve this

selected = False

If a widget is selected in its parent

../_images/selected.png

Python

ExampleWidget(selected=True)

KV

ExampleWidget:
    selected: True