Book Image

Raspberry Pi Essentials

By : Jack Creasey
Book Image

Raspberry Pi Essentials

By: Jack Creasey

Overview of this book

Table of Contents (15 chapters)
Raspberry Pi Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Project 3 – Creating a simple Python GUI for the security application


We will use a very simple Python application that presents two buttons. One button loads and unloads the raspivid and motion application services, and the second starts and stops recording (irrespective of motion detection).

Python does not have any window-based functionality; it is purely text input by default. To provide a GUI, you have to provide extension libraries and, in this case, we will use a library called tkinter. In the code, we will use tkinter to define the two buttons and will use the OS library to call out to our existing shell script to perform the needed actions.

Perform the following steps to create a Python GUI for your security script:

  1. Install python-tk using the apt-get command.

  2. Create a blank file in /home/pi/camera called buttons.py.

  3. Set the permissions for the file to be executable and ensure the ownership is set to the user pi.

  4. Double-click on IDLE 3 to open the Python development shell and use File...