Introduction to Kivy ; A Cross-platform Python Framework
Kivy is a graphical user interface open-source Python library that allows you to develop multi-platform applications on Windows, macOS, Android, iOS, Linux, and Raspberry Pi. The best thing about kivy is, it performs better than HTML5 cross-platform alternatives.
Note that it is necessary to have Python 3 on your machine to make use of the library.
Installation in Windows:
- Step 1: Update the pip and wheel before installing kivy by entering this command in cmd-
python -m pip install --upgrade pip wheel setuptools
- Step 2: Install the dependencies-
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew python -m pip install kivy.deps.gstreamer python -m pip install kivy.deps.angle
- Step 3: Install kivy.
python -m pip install kivy
It will result in something like the below image:
Installation in Linux:
- Step 1: Add the PPA by entering this command in terminal-
sudo add-apt-repository ppa:kivy-team/kivy
- Step 2: Update your package list using your package manager-
sudo apt-get update
- Step 3: Install Kivy
sudo apt-get install python3-kivy
Create an application
There are three steps of creating an application with kivy:
- Inherit Kivy’s App class which represents the window for our widgets
- Create a build() method, which will show the content of the widgets.
- And at last calling of the run() method.
This is python3 code to make a simple application that shows the desired text on the system’s screen:
To run this code open cmd(terminal in Linux) and go through the directory in which the code is saved and type this command-