Using Kivy with the official Raspberry Pi Touch Display

The guide below and example code will get you started setting up the Raspberry Pi touch display and getting Kivy working with it. Kivy is an "open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps." This guide assumes you have a fresh install of Raspbian (2015-05-05 release), an Internet connection, and the displaysc is connected and working. It also assumes that you're already familiar with Raspberry Pi enough to get yourself to the command line. You can run this code locally or via SSH. The command line is where you'll start.

Update your software. This is required with the 2015-05-05 Raspbian image in order to get touch working. This step will take a few minutes:

pi@raspberrypi ~ $ sudo apt-get update && sudo apt-get -y upgrade

Reboot:

pi@raspberrypi ~ $ sudo reboot

Back on the command line, check that touch input works by trying it in X11:

pi@raspberrypi ~ $ startx

If touch works, exit out of X11 and go back to the command line.

The next few steps will install Kivy. These instructions are based on the Kivy User’s Guide. Firstly, open the APT sources list:

pi@raspberrypi ~ $ sudo nano /etc/apt/sources.list

At the end of file, add the APT sources for Gstreamer:

deb http://vontaene.de/raspbian-updates/ . main

Type Control+X to exit nano. Then press Y and Enter to save the file. You'll be back on the command line.

Download and add the GPG key for the Gstreamer sources (If you get an error, gpg: keyserver receive failed: bad URI after the first command, just try to run that command again. You should see gpg: imported: 1):

As you'll see, touch doesn't work. To fix this, you need to make the same change to config.ini you made before, but to the root account's config file. Exit (Control+C) and copy over your home directory's Kivy configuration file to overwrite the root account's: