The Python Programming Language has taken me almost three years to learn. It was an undertaking I started when I retired from my job at Ryerson University. With little formal training in computer science and no continuing education classes that I could attend in Toronto, my only option has been to learn with a combination of online sources and with books. I can now look back and say my learning and development was hampered by the lack of simple, straightforward code examples from which I could learn from.
I was continuously amazed when searching the Internet for code examples only to come across thousands of complex answers to simple questions which (for me) was a real barrier to me learning to code. Not all of us learners on the Internet have advanced math skills, nor can we wrap our heads fully around all the elements associated with Object Oriented programming that accompany many API‘s. And until these concepts can be taught with simplicity, coding will –IMHO– be difficult to democratize.
After completing my first major open source project in Python (www.convergencejukebox.com) I realized how hard it had been to learn many of Pythons advanced concepts. While there are many basic introductions to Python on the Internet the simple ones always seemed to cover the same topics and it was rare to find anything that was intermediate that built one could build from simple code. These days I do seem to be able to put code together with confidence but when coding something new a lack of simple code examples out here in the cloud really slows me down as I learn it a new application.
In trying to improve upon what I learned over the past few years I decided it would be a good time to tackle a new GUI application for Python called Kivy (see above video on Kivy by Matt Richardson). My Jukebox project (also noted above) used Tkinter as it’s GUI. Tkinter is part of Pythons standard libraries and works fine as a GUI on Linux, Windows and Macintosh computers. I’d be lying if I said I had mastered Tkinter as I coded that project. After reading about Kivy’s features, coupled with my experience using Tkinter, Kivy’s concepts seem more logical to implement and some of its features are more modern in design.
Kivy has two concepts that I personally find hard to swallow:
- It’s object oriented (which in concept is great) but I’ve found its nomenclature difficult to understand. I don’t think I’m alone with my OOP struggles so simple code examples are a blessing to me when I actually find them.
- Kivy promotes using a separate file (.kv). It’s optional and its used to set properties of the various Kivy screen widgets. –The .kv file is something akin to CSS and HTML– Since I like all of my code in one file I opt not to use .kv file if I can avoid it. However much of the documentation to date employs using the separate .kv file and as such its hard for me find and synthesize relevant code examples.
But even with those drawbacks Kivy’s appeal to me is that the Python code written around it is portable to all platforms including IOS and Android. Kivy is fairly new with its first stable release in January of this year.
While the language appears to be well documented on its website, I find the example content created by the community to date lacking very simple examples. I’m facing the same struggle(s) I had learning Python. While I’m grateful people have taken the time to create example materials, too much of the content generated to date jumps almost immediately into Kivy’s cool features and –even worse– much of it seem to be the same material originating from the same source.
As well many of the initial adopters and testers of Kivy are seasoned computer professionals and the material produced is aimed at those with similar backgrounds. There is a lot of assumed knowledge in much of that material.
To my way of thinking training in Kivy (or any GUI) should start on building a simple button, switch and checkbox interface. For example today I wanted to find a simple basic program (in its entirety) that used a Kivy checkbox on its user interface… Think I could… Nope….
from kivy.app import App from kivy.uix.button import Button class TestApp(App): def build(self): return Button(text='Hello World') TestApp().run()
While I expected Kivy’s learning curve to be steep, it took me almost three weeks for the “penny to drop” on how to format a basic Kivy interface. The Kivy “Hello world,” example is easy (above) and it comes with complete simple code… (Thanks Kivy.org…) But after setting up the Kivy library on my PC, advancing skills in Kivy became a mind numbing adventure to find simple code that explained how to put a basic interface together. It then became another adventure to find out how to get a button to actually do something and today –for example– it took another morning of my life to understand how to get a checkbox to work. Kivy’s new, people are working hard to get the code to work, and –yes— I understand that it takes time to develop an understanding of something that is this new.
So what I thought I would do is use my blog to publish several short simple Kivy code snippets, outlining what I learned about applying Kivy from a non mathematician or computer scientist perspective. They’ll appear as I learn the required concepts and I can simplify their explanation. Hope you find them useful.
Here is the link to the next post: Kivy For The Non Computer Scientist – Part 2: Concepts To Get A Handle On