Quantcast
Channel: Matt Huisman
Viewing all articles
Browse latest Browse all 191

Raspberry Pi PySide Minimal Image | Perfect for GUIs | Updated 04/03/16

$
0
0

Here is an image I have created to get people quickly into creating a Python GUI on the Raspberry Pi.

Features:
- Version 0.6
- Based on my Jessie Minimal Image
- Latest Jessie kernel and user space (as of 04/03/16)
- Boots directly to Python example GUI written using PySide
- Runs bare bones Xorg
- Uses Openbox as simple small window manager
- Disabled keyboard /mouse shortcuts in Openbox
- Runs under user Pi for better security
- Boots into GUI in approx 8 seconds
- Quiet boots into GUI (no console text etc)
- Works on all Raspberry Pi's (including Pi Zero and the new Pi3)
- Includes WiFi and Bluetooth Drivers (for Pi 3)

Download Info:
Download Size: 208MB (.7z)
Image ISO Size: 869MB
Use 7zip to extract image

Download Link:

Instructions:
- Download the file
- Unzip using 7zip
- Burn the .img file to SD card
- Boot in Raspberry Pi (any version)
- Raspberry Pi will reboot twice initially while setting up
- You will find yourself in a very simple example GUI

Login:
root / raspberry

Tips / Info:
1)
Run the below commands in terminal as root user to hide the mouse cursor (for touch screens)

sed -i 's/startx/startx -- -nocursor/' /etc/systemd/system/startx.service
systemctl daemon-reload

systemctl restart startx.service

2)
Run the below commands to calibrate your touch screen

systemctl stop startx

## Do calibration ##
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_FBDEVICE=/dev/fb0
ts_calibrate


## Do Xorg calibration ##
FRAMEBUFFER=/dev/fb1 startx &

DISPLAY=:0.0 xinput_calibrator

Copy the output of the above command

nano /etc/X11/xorg.conf.d/99-calibration.conf

Paste in the copied text and save the file (Ctrl-X, Y, ENTER)
It should look something like this

 

Now we kill X and start our app service.

pkill x
systemctl start startx


Done :)

2)
If your working on the GUI 'live' on the Pi, you can run the below command to restart X and the Python script

systemctl restart startx.service

I use WinSCP to have the Python file open in my favorite text editor (Sublime) so I can save it and it will be automatically uploaded.

Then I have a terminal open so I can simply run the above command to restart to see changes.

3)
Here is a run-down of the boot procedure and where to find everything

- A systemd service runs the command 'startx' as user Pi on boot
  This service file is located /etc/systemd/system/startx.service
- Startx calls the .xinitrc file in user Pi home directory which starts an openbox-session
  This file is located /home/pi/.xinitrc
- Openbox starts and runs it's autostart file
  This file is located in /home/pi/.config/openbox/autostart
- This autostart file runs a bash script in our app folder
  This script is located /home/pi/app/start.sh
- This script runs our python script in a forever loop (in case of crashes)
  The python script is located /home/pi/app/main.py

4)
User Pi has been given sudo privileges for one file only. This file is /home/pi/app/functions.sh
 
Any commands that require root privileges can be added to this file and then called from the Python script.
eg. os.system('sudo ./functions.sh reboot_system') which is used in the example.


Viewing all articles
Browse latest Browse all 191

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>