I recently received a copy of Kivy: Interactive Applications in Python by Roberto Ulloa. This is currently the only book about Kivy. Kivy is a cross-platform GUI toolkit that will run on Linux, Windows, and OS X as well as Android and iOS. In fact, the people behind Kivy emphasize that this is aimed primarily at mobile programming. Kivy supports multitouch and has a very active group of programmers. You can read more about Kivy on their project’s home page. I will be reviewing the PDF version of the book.

Here’s my quick review for those of you without a lot of time:

Quick Review

  • Why I picked it up: I received this book as payment for helping with the reviewing of another Packt book, but I would have bought it myself because I am interested in learning Python for Android/iOS and I like learning about Python GUI toolkits.
  • Why I finished it: The book is short and I was optimistic that it would get better.
  • Iā€™d give it to: Someone who already knows Python and the basics of Kivy, although I don’t think I would recommend it.

Book Formats

You can get this book in paperback, epub, mobi, or PDF.

Book Contents

The book is split into five chapters. The first four chapters cover the comic creator project, which is about creating shapes and drawing with Kivy. The reader is supposed to learn GUI basics (chapter 1), layouts (chapter 1), how to use the canvas object (chapter 2), widget events (chapter 3), improving the user experience (chapter 4) and the last chapter covers the second and last project, which is a clone of Space Invaders.

Full Review

The Kivy toolkit supports two languages. You can write your programs entirely in Python or you can do a mixture of Python plus the Kv language. The Kv language looks kind of like CSS+Python and it has indentation requirements similar to Python (i.e. each block must be indented 4 spaces). The first example of using the Kv language is not properly indented in the book. The author never mentions the need to indent the Kv code four spaces, so it took me a while to figure out why the code didn’t work. You will find that almost every example of Kv code in the book will not work if you copy it. Some of the Python code has indentation issues as well. Packt hires a lot of authors whose primary language is not English. This book has lots of examples of sentences that are difficult to read or just don’t make sense. Let’s look at each chapter.

The first chapter covers how to launch a Kivy application, how to add a widget or two, the properties / variables of widgets, the various coordinate systems of Kivy and layouts. The first couple of sections are pretty straight forward. The coordinates section is muddled and takes much re-reading to understand. I only understood parts of the layout section. Layouts in Kivy are analogous to sizers in wxPython. They help control how widgets are positioned dynamically when the user changes the window size.

Chapter two digs into Kivy’s canvas object. It covers how to draw shapes, insert images, how to use colors, scaling and translating. There is also information in this chapter about storing/retrieving the current coordinate space context. The image and color section was the highlight for me. The rest, not so much.

In chapter 3, we learn about event binding in Kivy. You get to learn how to override, bind, unbind, and create Kivy events. You’ll also learn about how to use properties to keep the UI up-to-date. The chapter purports to explain several other topics as well. I’m not sure I understood the author’s reasoning for constantly binding events and then unbinding them, but at least now I know how to do it. There’s a section about translating relative and absolute coordinates between widgets, the widget’s parent and the window itself. That section is confusing, but interesting too.

For chapter 4, we learn about screen managers. This concept makes it easy to switch screens, which is kind of like swapping panels in wxPython except that it’s built into Kivy. It also talks about a Color Control widget, creating and saving gestures, and multitouch for drag, rotate and scaling. The gesture portion of the chapter was intriguing, although I didn’t think it was explained in enough detail. Kivy actually has classes built into it specifically for saving and retrieving custom gestures. I wish this section mentioned how accurate Kivy is at recognizing gestures, but it doesn’t.

Chapter 5 is all about the clone of Space Invaders. This chapter is only 20 pages, so I don’t think it gives enough detail about how everything works. It felt rushed to me. On the other hand, I enjoy learning how to create games, so I’ll give the author props for that. And there was a lot of cool information in the chapter. You just have to spend most of it deciphering the code though.

In the end, I was left wanting to know more about Kivy. I found Kivy’s documentation much more helpful than the book, but the book at least had some interesting ideas in it. I think that’s its most redeeming value. It makes you want to learn Kivy so you can improve the two projects in the book and make your own. One key topic that I think is sorely missing is the actual distribution of the projects to one or both of the mobile platforms as well as how to go about testing on those platforms. Does Kivy work in an Android or iOS emulator? Does Kivy have more than 7 or 8 widgets? These questions aren’t answered. If you can get the book cheap, I would say go for it. Otherwise, stick with the Kivy documentation and demo programs.

kivy_book

Kivy: Interactive Applications in Python

by Roberto Ulloa

Amazon

Packt Publishing

Other Book Reviews

Additional information about Kivy

Print Friendly