Using swappable widgets

There are some situations wherein you need to shift a widget, but then you realize that it is not necessary to define a new class for it. This is what we call the dynamics class, which allows us to work with different widgets. In this recipe, we want to create some buttons from a list that will swap a label in the app. Here, we will be using the screen manager widget.

Getting ready

This recipe is based on some advanced KV concepts, thus it is advisable to read the recipe Reusing styles in multiple widgets from Chapter 1, Kivy and the Kv language. Also go through the previous recipe Manipulating the widgets tree to understand the differences between them.

How to do it…

To complete this task, follow the next steps:

  1. In the KV file, ...

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.