Triggering events
If we want to schedule the events, we can trigger them, which will help you trigger the same event in different parts of your code. In the next described recipe, the event will be triggered when we double tap.
Getting ready
Again, we are going to make use of the double tap, so it is important that you refer to the recipes in Chapter 2, Input, Motion, and Touch. Even though the skeleton of the code is similar to that for the last event, the actions are completely different. Here the unscheduling will be automatic.
How to do it…
Perform the following steps to achieve the goal:
- First, in the KV file, declare an empty label using the following code:
<MyW>: Label: id: label1 pos: 200,200 text: ''
- In the Python code, import the
Clock
object instance. - In the widget class, define the method
my_callback()
. - Also, define the method
on_touch_down()
where we will define the trigger. - As shown in the following code, using an
if
statement, select...