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

Kivy and its properties


Even though we have only touched upon explanations of properties in the previous section, the truth is that we have been using them since the beginning of this chapter. Kivy's internals are full of properties. They are almost everywhere. For example, when we implemented DraggableWidget, we simply modified the center_x property (line 72 and 73), and the whole Widget was then kept updated because there is a chain of properties involved in the use of center_x.

The last example in this chapter illustrates how powerful Kivy properties are. Here is the code for statusbar.py:

273. # File name: statusbar.py
274. from kivy.uix.boxlayout import BoxLayout
275. from kivy.properties import NumericProperty, ObjectProperty
276.
277. class StatusBar(BoxLayout):
278.    counter = NumericProperty(0)
279.    previous_counter = 0
280.
281.    def on_counter(self, instance, value):
282.        if value == 0:
283.            self.msg_label.text="Drawing space cleared"
284.        elif value...