Python’s Kivy — Self, Root, App?
Do you know when to use each of these?
Ah Kivy, a great open source Python framework for developing multi-platform GUIs.
I have been wanting to use this framework for a long time but often got stuck on how to access properties/data between the Python file (.py) and the Kivy file (.kv).
After reading Kivy documentation, Stack Overflow posts, and watching YouTube videos, I still found myself confused on when to use ‘self’, ‘root’ and ‘app’ and even worse… ‘app.root’!?
So I wanted to sort this out once and for all and create a Kivy App that describes its own behaviour for referencing self, root and app. You could call it a ‘Cheat Sheet’ that may also help you if you forget how to access a property or object in Kivy.
If you already have Kivy installed, please feel free to copy and paste the code below into your text editor of choice, save it as main.py and run it.