Creating your own events – the magical properties
This section covers the use of the Kivy properties. A Kivy property triggers an event every time we modify it. There are different types of properties, from the simple NumericProperty
or StringProperty
to much more complex versions such as ListProperty
, DictProperty
, or ObjectProperty
. For example, if we define a StringProperty
called text
, then an on_text
event is going to be triggered each time the text is modified.
Note
Once we define a Kivy property, Kivy internally creates an event associated with that property. The property event is referenced adding the prefix on_
to the name of the property. For example, the on_translation
method (line 246) is associated with ListProperty
in line 219 called ...
Get Kivy – Interactive Applications and Games in Python - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.