Quick search

See ButtonBehavior for details.

class kivy.uix.behaviors.button.ButtonBehavior(**kwargs)[source]

Bases: object

This mixin class provides Button behavior.

Events:
on_press

Fired when the button is pressed.

on_release

Fired when the button is released (i.e. the touch/click that pressed the button goes away).

MIN_STATE_TIME = 0.035

The minimum period of time which the widget must remain in the ‘down’ state.

..warning::
This is deprecated, and will be removed in the next major release. Use min_state_time instead.

MIN_STATE_TIME is a float and defaults to 0.035.

always_release

This determines whether or not the widget fires an on_release event if the touch_up is outside the widget.

New in version 1.9.0.

always_release is a BooleanProperty and defaults to True.

last_touch

Contains the last relevant touch received by the Button. This can be used in on_press or on_release in order to know which touch dispatched the event.

New in version 1.8.0.

last_touch is a ObjectProperty and defaults to None.

min_state_time

The minimum period of time which the widget must remain in the ‘down’ state.

New in version 1.9.1.

min_state_time is a float and defaults to 0.035.

state

The state of the button, must be one of ‘normal’ or ‘down’. The state is ‘down’ only when the button is currently touched/clicked, otherwise its ‘normal’.

state is an OptionProperty and defaults to ‘normal’.

trigger_action(duration=0.1)[source]

Trigger whatever action(s) have been bound to the button by calling both the on_press and on_release callbacks.

This simulates a quick button press without using any touch events.

Duration is the length of the press in seconds. Pass 0 if you want the action to happen instantly.

New in version 1.8.0.