There are several open source and GUI based interface development programs or applications are available in market today. Developers are mostly working on mobile or web applications. These applications or programs help to quickly develop mobile applications and multi touch application software by directly accessing mobile APIs to manipulate various components like camera on phone, GPS tracking etc.
Today we look at Kivy which is one such GUI based user interface for Python programming language and understand its functionality and usage and learn about its applications.
Introduction to Kivy
Python programming language is one of the topmost popular choice for application development due to its excellent library support to build world class applications. Once such library is Kivy in Python it is a cross platform library and used to build multi touch application primarily for mobile devices / users. It is an open source python library having a natural user interface and runs on various operating system platforms such as Windows, OS X, Linux, Raspberry, Pi, Android etc. Kivy has stable interface and well documented APIs library. The graphic engine of Kivy is based on OpenGL ES2 and has more than 20 widgets which are highly extensible. It comes under MIT license and 100% free.
Key reasons for the widespread use of Kivy by developers:
- Elegant built in support for multi touch devices
- Only viable way to code in python on mobile devices
- Replaces the horrible APIs of earlier graphical user interfaces like HTML and CSS
- Allows to maintain a single application across multiple operating systems
It was first released in early 2011. This cross-platform python framework can be deployed on Windows, Mac, Linux, and Raspberry Pi. It is creating a natural user Interface (NUI) which user can learn easily with little or no instruction. Kivy is an interesting graphic user framework which can be used to create desktop user interfaces and mobile applications for both iOS and Android.
The architecture comprises of following elements:
Core providers and input providers
- Kv Language
- Input events
- Widgets and Input dispatching
Core providers and Input providers – core tasks comprise of basic tasks such as opening a window, playing an audio, displaying images, displaying text, spelling corrections etc. these makes APIs both easy to use and extend. An API is used to talk to operating system on one hand and other side to the Kivy acts as intermediate communication layer (a piece of code).
An input provider is a piece of code which adds support to specific input device such as Apple trackpads, TUIO or a mouse emulator.
Graphics – Graphic API can automatically optimize the commands to draw.
Core – core package contains commonly used features such as clock to schedule timer events, cache to do a something often, gesture detection to recognize different types of strokes like circles, rectangles etc.
Kv language – is used to describe user interfaces easily and efficiently. It is a domain specific language ideal for laying out user interfaces.
UIX – contains widgets and commonly used layouts. Widgets are user interface elements which are added to a program to provide some sort of functionality such as File browser, buttons, sliders, lists etc
Modules – are used to inject functionality into Kivy programs.
Input events – play an important role and Kivy input events examples are touches, mice, TUIO, Mouse, MTDev and HIDinputs.
Widgets and Input dispatching – are frequently used in GUI programming to explain part of a program which interacts with user. In Kivy widgets work as an object which receives input events and arranged in form of a widget tree. Widget may have one or more child.
Pros and Cons
- Helps to design multi innovative interfaces with multi touch functionalities
- Well documented APIs
- Run code on all platforms
- Smoothly works on multiple platforms – Windows , Android, Linux, iOS, MacOS, Raspberry Pi etc
- Better presentation of programs such as classes, widget configuration and inherited classes
- Not suitable to compile code alone as it is KV language dependent
- Not up to date with latest Android APIs
- Lot of time for building and compiling mobile applications
- Package size is huge
- Lack of community support
To install Kivy on Linux operating system type the following commands:
- sudo add-apt–repository ppa:kivy-team/kivy
- sudo apt-get update
- sudo apt-get install python-kivy
To install kivy on Windows operating system type the following commands:
- Download Kivy from http://www.kivy.org/#download
- Once the Kivy Zip file is downloaded, unzip the package in some folder
- Open that folder and copy the kivy.bat file
Open Windows Explorer and in the address bar, type shell: SendTo Paste kivy.bat as a shortcut.
This shortcut is used to launch the Kivy application