Creating your own events – the magical properties
This section covers the use of 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 like 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 text is modified.
Note
The on_translation
method (line 243) is associated with the ListProperty
in line 216 called translation
. Once we define a Kivy property, Kivy internally creates an event associated with that property. The property name is generated adding the prefi x on_ to the name of the property.
All the properties work in the same way. For example, the state
property of ToogleButton
is actually a property which creates the on_state
event. We alreadsed this event in line 203. We define the property and Kivy creates the event for us.
Note
In the context...