Book Image

Kivy - Interactive Applications and Games in Python

By : Roberto Ulloa
Book Image

Kivy - Interactive Applications and Games in Python

By: Roberto Ulloa

Overview of this book

Table of Contents (13 chapters)
Kivy – Interactive Applications and Games in Python Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Behaviors – enhancing widget's functionality


Behaviors were introduced recently in the Kivy version 1.8.0, and allow us to increase the functionality and flexibility of the existing widgets. Basically, they let us inject classic behaviors of certain widgets into other behaviors. For example, we can use ButtonBehavior in order to add the on_press and on_release functionality to a Label or Image widget. Currently, there are three types of behavior (ButtonBehavior, ToggleButtonBehavior, and DragBehavior) and more will be coming in the next Kivy releases.

Let's add some credits to our application. We want to add some functionality to the Status Bar so that when we click, a Popup will appear and show some text. First, we will import the necessary components into the statusbar.py header, and also change the class definition of StatusBar:

312. # File name: statusbar.py
313. import kivy
314. from kivy.uix.boxlayout import BoxLayout
315. from kivy.properties import NumericProperty, ObjectProperty...