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

Declaring a property


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.

Getting ready

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.

How to do it…

The recipe is:

  1. First, import the ListProperty from Kivy properties.

  2. Create the class for the root widget.

  3. Add two button widgets into the root widget.

  4. Reference the CustomBtn widget, bind it, and add it.

  5. Create the class for the CustomBtn widget and declare the ListProperty.

  6. Define the on_touch_down method to perform the change of the property...