O'Reilly logo

Kivy Cookbook by Hugo Solis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using StackLayout

The StackLayout widget refers to stacking boxes, so it stacks the widgets one over another In this recipe, we will stack four buttons of different sizes to see the behavior of the layout.

Getting ready

In this recipe, we will use the Python code similar to the code in the recipe Using the BoxLayout. I would recommend you to go through the preceding recipe.

How to do it…

In this recipe, we will use the KV file to set the StackLayout and its children. The Python file is a code that we have been using in the layouts. Follow the next steps:

  1. In the KV file, define a StackLayout child widget.
  2. Using the orientation property, give an orientation for stacking.
  3. Define a button as a child of the StackLayout widget, which should be 50 percent of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required