Attaching callbacks
Now, we have created a new kind of event, so it is possible to attach callback methods to our new event as we have in the predefined events. For this recipe, we will create a new event and attach a callback function to it. If the button text changes, the event as in the past recipe will be fired.
Getting ready
We will use the code from the previous recipe as the base of this recipe and will add a different touch so that we can change the button when it is double tapped. Hence, I would advise you to go through the previous recipe again. Also, the reader may find the section on multitouching from Chapter 2, Input, Motion, and Touch useful specifically.
How to do it…
Perform the following steps:
First, in the KV file, declare an empty label and a button:
<MyW>: Button: id: button1 text: 'Hello' Label: id: label1 pos: 200,200 text: ''
In the Python code, define the callback method.
Define the widget class.
In the widget class...