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

Working with the accelerometer


Nowadays, it is common that mobile devices are equipped with an accelerometer. Thereby, it is relevant to consider this input to develop fancy apps. The accelerometer is one kind of event that is considered as a no-touch event because it has neither start nor an end, it is always providing information.

Getting ready

In this recipe, we will use the Kv language for the design of the widgets, so, again, you will need to be familiar with the Kv language. Also, this recipe will use the common button and label widgets for reference. Obviously, to get more benefit, a device with an accelerometer is useful to run the code.

It is necessary to install a package for the use of the accelerometer in any mobile device; there is a way to deal with every specific device, but we do not have to reinvent the wheel. Let's use a Plyer package, which is an effort from many of the Kivy developers. To install the package from the shell, use:

$ sudo pip plyer install

Here where we are...