Available for the Raspberry PI at the actual date the market offers a number of touch screen displays; the recent launched Raspberry PI 7" LCD touch screen displayRaspberry PI 7" LCD touch screen display and the 2.4" HAT display2.4" HAT display are the top accessories in their range. These devices can be used as primary display including the touch screen they can replace the standard HDMI display, USB keyboard and mouse.


It is almost obvious that the 2.4 inches screens are less useful than larger screen (i.e. 15 inches or more): but represent a great solution for a large number of projects and applications.

A common UI design is difficult to manage and more difficult to interact with when the user should manage a 2.4 inches (or less) small screen or trying to use complex interactive interfaces also on a 7 inches screen.


Take a look to the following video.

If you like this kind of interface you are in the right place. Full colour graphics, multi-touch management, easy and visible interaction widgets also on small screen sizes, reasonably fast and responsive interfaces and more. The features shown in the video above are only some of what can be achieved with the Kivy python framework.

Note: the frame assembly of the Raspberry PI LCD Touch Screen display shown in the images of this post is available on the Drobott site. Don't forget to apply the Element14 discount code W0E49MYQ (10% off) reserved to the community users!


The framework

The adoption of this framework for the User Interface with the Raspberry PI is the better solution when the touch screen is the main tool to interact with the application. For the developers this framework is simple to manage, entirely developed in Python and very well documented with plenty of examples.


Wikipedia reports the definition of the Kivy framework as

Kivy is an open source Python library for developing mobile apps and other multitouch application software with a natural user interface (NUI). It can run on Android, iOS, Linux, OS X, and Windows. Distributed under the terms of the MIT license, Kivy is free and open source software.

but the term library is reductive; kivy is a set of libraries integrating features of many different environments. The recent porting available for the Raspberry PI Raspbian makes kivy one of the best solution for the UI design on touch screens and small displays.


The X desktop (the Raspbian desktop is an example) has never been though to be controlled by a touch-screen or an on-screen keyboard. In fact the kivy framework works perfectly just in these cases, so it's time to move on the Raspberry PI terminal and start the installation.


Installing Kivy on Raspberry PI

The main reference site is On the site - not reported in the documentation index - there is a short page with a tutorial on Installing kivy on Raspberry PI. Unfortunately this is the only page I have found and is a bit outdated. The actual available version of the framework runs perfectly on all the Raspberry PI models including the PI 2, despite that the documentation report as untested.


Installation options

Two installation options are possible: the manual installation under Raspbian and the Kivy distribution image for the Raspberry PI.

I have tested both. The special PI distribution (derived by Raspbian) can be downloaded from the site KivyPie - Kivy on RaspberryPI but seems not well working so we will exclude this option and take in consideration just the manual installation.


Manual installation

The first thing to do is adding the repository to the list. From the terminal launch the editor


$>sudo nano /etc/apt/sources.list


and add the following line: deb . main

The resulting file will show like in the image below.

Screen Shot 2015-10-01 at 23.09.03.png

Save the file then launch the next commands:


$>sudo apt-get update
$>sudo apt-get upgrade


Before installing the framework you should install the dependencies of the packages:


sudo apt-get update
sudo apt-get install pkg-config libgl1-mesa-dev libgles2-mesa-dev \
  python-pygame python-setuptools libgstreamer1.0-dev git-core \
  gstreamer1.0-plugins-{bad,base,good,ugly} \
  gstreamer1.0-{omx,alsa} python-dev


Note: you will receive a warning for some uncertified packages. Ignore this message and confirm when required to proceed.


The next step needs to install pip from the sources. Pip, aka Pipi is the Python Package Index; It is a specific python packages repository working in a similar way of the apt-get (the aptitude Debian package manager). A full detailed list of the available packages in pip is available on the pipi-python site.


sudo python


Installing and compiling the pip package manager on the Raspberry PI may require 10 minutes or more. Don't worry and wait ... During the installation you will get some error messages due the wheel command is not found; don't stop the process and ignore these messages. Wheel is a package image builder not intended for use in our case. The error message you get is shown in the image below.

Screen Shot 2015-10-01 at 14.21.33.png

Cython is the c-extension for python and is used by some components of kivy. For a detailed description see the cython wiky.

At the end of the process described above cython should be installed in your system. We use the pip repository to acquire the last updated version, avoiding the eventually outdated version available in the Debian packages.


sudo pip install cython


At this point, we are are ready to clone kivy from GitHub and compile it locally


git clone
cd kivy


Fine! We have completed the most boring part. The kivy sources now are in the user home directory, for example the user pi. It is also possible to install kivy only in the user folder but this way creates many issues when developing applications that will rung accessing other folders so we install the framework globally.


python build
sudo python install


The two commands above should be launched from inside the kivy directory in the user folders. You should already be there when the step ends. This operation requires 5-15 minutes or more, depending on the hardware model and processor speed of your Raspberry PI board.

A couple of other steps and our newly installed framework is ready for the first run.


Post-install settings

There are some features of the kivy framework requiring some external components to be installed afte the framework installation is complete.


sudo pip install pyglet docutils
sudo pip install pygments


The last operation is to edit the user kivy configuration file to set the raspberry PI touch screen replacing the mouse. Edit the kivy configuration file with the command


nano ~/.kivy/config.ini


and add the following lines in the [input] section (other similar lines should be replaced)


mouse = mouse
mtdev_%(name)s = probesysfs,provider=mtdev
hid_%(name)s = probesysfs,provider=hidinput


Save the file and reboot the system. Now you are ready to launch your application or run the examples in the folders you find in ~/kivy/examples