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 ActionBar


The ActionBar widget is like the popular Android's ActionBar. Here the children are stacked in horizontal and vertical groups such as menus. This recipe will use the ActionBar widget to organize eight buttons, and the bar will be the superior part of the app that has two buttons.

Getting ready

In this recipe, we need an icon such as the commonly used save icon. For this purpose, we will use the image floppy.png, which looks like:

How to do it…

Here, we will use a KV file to set and organize ActionBar and its children and the Python file to add ActionBar to our app. To complete the task, perform the following steps:

  1. In the KV file, define the rule <MyW>.

  2. In this rule, add the ActionBar widget.

  3. In the ActionBar child, add a button with the floppy.png icon.

  4. Add three more buttons.

  5. Add three child buttons to ActionGroup.

  6. Define another rule <MyW> with two buttons using the following code:

    <MyW>:
        ActionBar:
            pos_hint: {'top':1}
            ActionView:
       ...