Book Image

Kivy Blueprints

By : Vasilkov
Book Image

Kivy Blueprints

By: Vasilkov

Overview of this book

This book is intended for programmers who are comfortable with the Python language and who want to build desktop and mobile applications with rich GUI in Python with minimal hassle. Knowledge of Kivy is not strictly required—every aspect of the framework is described when it's first used.
Table of Contents (12 chapters)
10
A. The Python Ecosystem
11
Index

Making tiles

This part of the chapter is devoted to building the Tile widget. Tiles are more dynamic in nature than, for example, the Board widget that we've seen earlier. To account for this, we are going to create a number of Kivy properties on the Tile class so that any visible change to tile automatically leads to redrawing it.

Kivy properties differ from regular Python ones: a property in Python is basically just a variable bound to an instance of class, possibly coupled with getter and setter functions. In Kivy, properties have an additional feature: they emit events when changed and as such you can observe interesting properties and adjust other related variables accordingly, or perhaps repaint the screen.

Most of this work happens under the hood without your intervention: when you issue a change to, for example, the pos or size of a widget, an event (on_pos or on_size respectively) is fired.

Interestingly, all properties that are defined in a .kv file are propagated automatically...