Hello, Kivy
When learning a new programming language or technology, the first thing demonstrated to students is traditionally a "hello, world" program. This is how it looks in Python:
print('hello, world')
The Kivy version of a "hello, world" is a little lengthier and consists of two files, namely, a Python module and a .kv
layout definition.
Code
A Kivy application's entry point is customarily called main.py
, and its contents are as follows:
from kivy.app import App class HelloApp(App): pass if __name__ == '__main__': HelloApp().run()
As you can see, this takes Kivy's App
class, adds absolutely nothing to it, and calls run()
.
Layout
A layout file is typically named after the application class, in this case HelloApp
, sans the App
suffix and in lowercase: ...
Get Kivy Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.