Project: Electronics Bash - #24- Visual Displays in Python


Some get into programming computers to look at data on a chart, but let's be real - we want to make shiny things in lots of pretty colors! Today we're looking at how to use a fundamental graphics library to make visual displays in Python on the Raspberry Pi.

Topics Include:

  • The PyGame library
  • Drawing to the Screen
  • Primitive objects (lines, rectangles, circles)
  • Including images
  • The perpetual loop


Code

Pygame - Hello World

Click here to view code on Github

Pygame - Draw Circle

Click here to view code on Github

Pygame - Draw Rectangle

Click here to view code on Github

Pygame - Draw Primitives

Click here to view code on Github

Text

Click here to view code on Github

First Movement

Click here to view code on Github

Keyboard Movement

Click here to view code on Github

Clock

Click here to view code on Github

Mouse

Click here to view code on Github

Mouse Squares

Click here to view code on Github

Minesweeper Starter

Click here to view code on Github

Resources and Links

Links and Resources:
Raspberry Pi Homepage: https://www.raspberrypi.org/
Raspberry Pi OS: https://www.raspberrypi.org/downloads/
MagPi Magazine: https://magpi.raspberrypi.org/
Python Reference: https://docs.python.org/3/tutorial/index.html

Getting Started:
Raspberry Pi Imager: https://www.raspberrypi.org/downloads/
Troubleshooting Guide: https://www.raspberrypi.org/learning/troubleshooting-guide/
Display Troubleshooting: https://www.raspberrypi.org/documentation/hardware/display/troubleshooting.md
Starting w/o a Monitor: https://bit.ly/33IvKCc

Materials:
Video on Raspberry Pi Supplies: https://youtu.be/zeHvQZzkxbk
Raspberry Pi 4: https://www.adafruit.com/product/4292
Power Supp;y: https://amzn.to/2PiU6u6
MicroSD Card: https://amzn.to/2EHfHdA
MicroSD Card Reader: https://amzn.to/2EEmNiR
Micro HDMI to HDMI Cable: https://amzn.to/3jWffYW
Keyboard and Mouse: https://amzn.to/39LRX3v
Cat5 Cable: https://amzn.to/2EzoJcm

Some of the above links are Amazon affiliate links - ordering products through these links provides a small amount of support to the channel at no cost to you.