The Kivy Python GUI framework is intriguing.
Not only it’s cross-platform but also supports Android. Java is too verbose and low level for me and Kivy is an opportunity for developing native Android apps without leaving Python.
Outside of the Kivy project documentation, there are few third-party advanced tutorials that go in more depth than the official tutorials. So, before diving into the code of the Kivy demos, I wanted some books to explore more features and get a broader picture of the framework and what it can do.
I found two potentially interesting books: Building Android Apps in Python Using Kivy with Android Studio: With Pyjnius, Plyer, and Buildozer by Ahmed Fawzy Mohamed Gad (Apress, 2019), and Kivy – Interactive Applications and Games in Python – Second Edition by Roberto Ulloa (Packt, 2015).
I read both and here are my impressions.
Building Android Apps in Python Using Kivy with Android Studio
I had much hope for Building Android Apps in Python Using Kivy with Android Studio as its focus is Android. And it was published just a few weeks ago, so it may be the most up to date of the books about the framework.
But I don’t recommend the book.
|The cover of Building Android Apps in Python Using Kivy with Android Studio in Google Play Books on my Pixel 2 XL.|
It’s poorly edited, often repetitive, and, despite the size, covers only a handful of widgets, layouts, and Kivy features. The few interesting tidbits here and there aren’t worth the price.
As a non-native English speaker and author I face the same difficulties in writing about complex technical topics in an unfamiliar language. Had the book been self-published, I wouldn’t have minded some editing issues. But I hold a large publishing house to higher standards.
The book presents a few sample apps it progressively builds on and enhances. In most cases, each new version includes the full source code of the previous versions, which sometimes makes it difficult to spot new or changed features. This, along with the poor editing, makes reading bumpy.
Kivy with Android Studio is an oxymoron. The point of using Python to develop Android apps is to not have to use Java, so this part of the book is useless to me. I’d prefer more examples of what Plyer can do without Java.
Despite all this, the author knows his stuff. I hope for a new, improved edition that keeps the focus on Android and Python, tells how to make apps responsive on a variety of screens, expands on Plyer, and drops Java.
Kivy – Interactive Applications and Games in Python
Kivy – Interactive Applications and Games in Python is the learning resource I was looking for.
At over half the size of Gad’s book, Ulloa’s is much better. It covers many more Kivy features that help develop complex, attractive, responsive apps with a wide variety of layouts and widgets.
|The cover of Kivy – Interactive Applications and Games in Python in Google Play Books on my Pixel 2 XL.|
Aside from a game, the book discusses apps that showcase several advanced widgets and features of desktop and mobile user interfaces. The sample apps display fairly complex data, have a variety of user interface controls, and showcase different interaction techniques.
Ulloa anticipates the learning roadblocks and difficulties and clarifies some subtleties of Kivy. For example, code like this in the KV file of Kivy’s reStructured Text editor demo had me puzzled as it has the same identifier at both sides of a statement:
Ulloa explains the left one is a widget attribute, the right one a widget ID. To avoid confusion, he uses a different style in which IDs start with an underscore, like this in the previous example:
According to the Kivy blog’s review of Kivy – Interactive Applications and Games in Python, the chapter on events and event binding is dense and difficult to grok. As a Kivy and Python beginner this wasn’t my impression. However, the coordinate transformations that event handlers often perform may be difficult to visualize.
The code fragments are often short and easy to follow but the book has a formatting issue that interferes with reading the code. In the ePub version of the ebook I bought at Google Play Books, the width of source code blocks is too narrow and most of the lines wrap.
Ulloa’s book covers enough building blocks to bootstrap my understanding of Kivy and continue on my own.