Python is one of the most popular languages in the world. And kivy is the popular GUI framework for python that helps you create program with awesome gui. Moreover it has support to make app for windows, linux, IOS and android and so on. It is packaged with button, label, text, checkbox and many other ui elements and many more features . But the question is, how can I integrate it so that, i can start working with it. This article is to help you know that.
Working with kivy needs you to have
- good understanding on python along with OOP.
- Python 3.4 at most(*)
First thing is installation. There are three easy steps that you have to follow to it.
- Make sure you latest pip and wheel installed
python -m pip install --upgrade pip wheel setuptools
2. Install the dependencies.
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew python -m pip install kivy.deps.gstreamer --extra-index-url https://kivy.org/downloads/packages/simple/
3. Finally install kivy
python -m pip install kivy
Create your first application :
To create a kivy application you have to
- import kivy’s packages needed for your application
- create sub-class of the its “App” class
- implement its build() method so it returns a Widget instance (the root of your widget tree)
- instantiating this class, and calling its run() method.
from kivy.app import App from kivy.uix.label import Label class MyApp(App): def build(self): return Label(text='Helloworld') if __name__ == '__main__': MyApp().run()
Run it and you will find your app’s main window rendered. This is not much nice, but exciting enough as your first GUI app, not that ?
That’s how you can start with kivy. Keep learning and practicing.
You can check official documentation here : https://kivy.org/#home
* Currently, it is not supporting version 3.5 but hopefully will be available in the near future.