Book Image

Kivy Cookbook

By : Hugo Solis
Book Image

Kivy Cookbook

By: Hugo Solis

Overview of this book

Table of Contents (16 chapters)
Kivy Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Scheduling a repetitive event


After our first recipe, we can think about how to schedule a repetitive event. The present recipe will use one touch in the app to schedule the event and a double touch to unschedule the event.

Getting ready

We will use the knowledge about inputs from Chapter 2, Input, Motion, and Touch, particularly for this recipe, and will use multitouching to perform our actions. Also, it is useful to know that the label is a basic widget in the Kv language.

How to do it…

To complete this recipe, perform the following listed steps:

  1. First, in the KV file, declare an empty label. The following code will help you do this:

    <MyW>:
        Label:
            id: label1
            pos: 200,200
            text: ''
  2. In the Python code, import the Clock object instance.

  3. In the widget class, define the method my_callback(), which is the method that will be fired.

  4. Also, override the method on_touch_down() where we can schedule the repetitive event.

  5. With an if statement, select a double tap and unschedule...