This recipe will work with the last type of events, which is the property event. To be very specific, we will create an invisible widget that will fire an event when a selected property is changed. Just to identify of this invisible widget, we surround it with two normal buttons; thus, the section between them is our invisible widget.
The properties in Kivy have been reviewed in Chapter 1, Kivy and the Kv language, specifically with in the Declaring properties within a class recipe. Thus, it will be useful to refer to this recipe and also to the section on multitouching from Chapter 2, Input, Motion, and Touch.
The recipe is:
First, import the
ListProperty
from Kivy properties.Create the class for the root widget.
Add two button widgets into the root widget.
Reference the
CustomBtn
widget, bind it, and add it.Create the class for the
CustomBtn
widget and declare theListProperty
.Define the
on_touch_down
method to perform the change of the property...