Introducing animations

The use of graphics opens up a diversity of options: one of them is animations. Kivy is useful for this task. For this recipe, we will develop a simple animation of a button where, if you touch it, the animation is performed.

Getting ready

Animations are a natural extension of the graphics concepts. It is good to have those concepts clear so, as recommended, you should read the previous recipes of this chapter.

How to do it…

Here we are going to use KV file where we set the button to perform the animation that will be defined in the Python file as a method of the root widget class. For this, follow these steps:

  1. In the KV file, define the rule for the root widget.
  2. Add a button to the root widget.
  3. Call the root.animate() method in ...

Get Kivy Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.