Kivy (from official site)- Open source Python library for rapid development of applications that make use of innovative natural user interfaces (NUI), such as multi-touch apps.
Kivy Installation and Some Forplay
Following is mainly taken from Richardson Git link and modified for Arch Linux.
Installation It takes quite a while for Raspberry PI since it takes quite a few dependencies. As said by Kivy: “We try not to reinvent the wheel, but to bring something innovative to the market. As a consequence, we’re focused on our own code and use pre-existing, high-quality third-party libraries where possible. To support the full, rich set of features that Kivy offers, several other libraries are required.” So… be patient…123yaourt -S python-kivy
Launch the multi touch pictures demo. This will initialize the config.ini.123$ python ~/kivy/examples/demo/pictures/main.py
- Type Control+C to exit the pictures demo.
To enable touch, you’ll need to make a modification to the Kivy configuration file:123nano ~/.kivy/config.ini
Go into the [input] section, remove the lines that are in there and put in:12345mouse = mousemtdev_%(name)s = probesysfs,provider=mtdevhid_%(name)s = probesysfs,provider=hidinput
Launch the UI showcase. This shows you all the different UI elements that Kivy makes available to you:123python ~/kivy/examples/demo/showcase/main.py
If you’d like, explore the other examples in ~/kivy/examples/.
Try Kivy and GPIO together
download this repo to your Raspberry Pi if you haven’t already:12345# you will need gpio libraryyaourt -S python-raspberry-gpiogit clone https://github.com/mrichardson23/rpi-kivy-screen.git
- The example uses BCM GPIO pins 17 as a piezo buzzer, 27 and 10 as LEDs, and 22 as a button. Here is a Simple Guide to the RPi GPIO Header and Pins. In my case, I am using a tri-color LED for this demo: 27 red, 10 Green, 17 Blue, and 22 direct ground.
First try to run the example as root (root access is required for the GPIO library):1234$ cd rpi-kivy-screen/$ sudo python main.py
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:123sudo cp ~/.kivy/config.ini /root/.kivy/config.ini
The demo video at Youtube -taken with iPhone 6S -is pretty impressive.
About the Author:Beyond 8 hours - Computer, Sports, Family...