Third party cookies may be stored when visiting this site. Please see the cookie information.

Home Family Days Out Raspberry Pi & Electronics Blog

Stewart's Blog

Stewart Watkiss website to the world ...

(Children, computing, first aid and other ramblings ...)

Model Railway – designing a G-Scale building for an outdoor model railway in the garden – part 1

November 24th, 2018

This is my first attempt at creating a proper scale model for 3D printing. In this case I am creating a weigh building in G-Scale. This has been a huge learning curve. I’ve since learned from some of the issues in the first model and so part 2 will improve on the techniques shown.

The model is based on a real building located at Winchcombe Station on the Gloucestershire and Warwickshire Steam Railway. The building is opposite the entrance to the station. See the photo below:

Weigh bridge building at Winchcombe Station on the Gloucestershire and Warwickshire Steam Railway

The 3D printed version is approximately in G-Scale (1:22.5 scale). This is also known as garden gauge railway, designed for narrow gauge trains running on 45mm track. It may also work well with 16mm model railways as the size is perhaps a little smaller than G-scale. The main difference between the real building and the scale model is that the model does not use the different coloured brick that is in a curved shape above the window and where the side walls meet the roof. The main reason for this is the time it would take for a feature that I expect few would actually notice if I hadn’t pointed it out.

3D printed model railway Weigh bridge building in G-Scale

Designing the model

The model was designed in TinkerCAD. In this version I have created the model in several parts.

  • The main part of the building from the floor to the top of the door
  • Upper part of the building (including the side walls up to the pitched roof)
  • Internal fireplace and chimney breast
  • Roof
  • Windows (not shown in the photo above)

In general this works, but in a later version I will combine the first three into a single model. The reason for this is that there was some warping of the upper part of the building (perhaps due to the bed temperature). Although this is something that I will need to revisit again in future when creating larger buildings.

The internal fireplace is something that I added as an afterthought on this model, but will be included directly in the next version.

I have created a short video on getting started with TinkerCAD which explains about how to create a simple brick wall.

3D Printer

The printer that I have is a Wanhao i3 Plus Duplicator. This is the perfect size for creating this 3D model, which fits fairly comfortably on the build plate. It would not be possible to create a larger building in a single print using this printer. If a larger building is required (as I hope to do in future) then the model will need to be separated in parts and then fastened together.

Brick effect PLA filament for 3D printer

One of the challenges was in finding an appropriate colour PLA to give a good brick effect. The problem with most suppliers is that the closest the provide is either red which tends to be a bright post box red colour, or brown which is too dark. I had tried experimenting with different colours with acrylic paint when creating a brick wall previously, but then I came across a brick effect PLA filament from Filo Alfa. I couldn’t find a UK supplier for the FiloAlfa PLA so I ordered it direct from the manufacturer in Italy. Unfortunately whilst the cost of the PLA is quite reasonable, the additional cost of shipping meant it was in fact very expensive. I am however very happy with the quality of the PLA which works very well in my Wanhao 3D printer.

Brick Effect PLA 3D printer element from FiloAlpha

The rest of the building (roof and window frames) is made using my normal 3D printer filament for which I normally use either Prima Value PLA (1kg reels) or Prima Select PLA (750g reels) depending upon the colour availability.


The latest version is now available. Information on how this was created is available at:

Details of the changes to the latest version are available version 2 of GScale model railway building.

JLL Piano – Raspberry Pi Music Clip player

October 15th, 2018

This project is called the JLL piano. This is a school project that my daughter created for her music homework. She needed to create a project that related to Jerry Lee Lewis and she created a mini piano that plays a short clip for a different song depending upon the key that is pressed.

Raspberry Pi Piano Hat

It uses a Raspberry Pi with a Pimoroni Piano Hat.

You first need to setup the Piano Hat using the Pimoroni Piano Hat install instructions. Then create the following in a text editor.
The program will work in Python 2 or Python 3.

You can of course change the music clips to be any music you prefer.

import pianohat
import time
from pygame import mixer

# Change key numbering (black keys = -1)
keys = [0,-1,1,-1,2,3,-1,4,-1,5,-1,6,7]

sound_files = [

def inc_volume(ch,evt):
if evt:

def dec_volume(ch,evt):
if evt:

# Change volume by amount specified 0 to 10 (+1, -1 etc.)
def change_volume (change):
#print ("Change volume "+str(change))
if change == 0 : return
# volume is 0 to 1 so divide by 10
delta = change / 10
new_volume = sounds[0].get_volume() + delta
if new_volume > 1:
new_volume = 1
if new_volume < 0: new_volume = 0 for this_sound in sounds: this_sound.set_volume(new_volume) def handle_note(channel, pressed): if pressed: channel = keys[channel] if (channel < 0): return mixer.stop() sounds[channel].play(loops=0) mixer.init(22050, -16, 2, 512) mixer.set_num_channels(13) sounds = [mixer.Sound(sound_file) for sound_file in sound_files] pianohat.on_note(handle_note) pianohat.on_octave_up(inc_volume) pianohat.on_octave_down(dec_volume) while True: time.sleep(0.001)

Programming games with Pygame Zero

October 15th, 2018

Recently I’ve been programming some games using Pygame Zero. Pygame Zero is combination of libraries and other code that interfaces with Pygame to make it easier to program graphical games (or other applications). I’ve created two games so far one of which is designed for the Picade, Raspberry Pi based mini Arcade Machine and the other second is mouse based.

Compass Game

This is the compass game. Use the joystick (or cursor keys) to move the character around the field.

Compass game for Raspberry Pi Picade

More details see:

Memory Card Game

This is the a memory card game. It’s mouse driven.
The supplied cards are based on photos from the Lake District in the UK.

Memory Card Game for Raspberry Pi

More details see:

Updated Linux and Raspberry Pi Tutorials

March 27th, 2018

One of the things about creating a web site is having to keep it up-to-date as changes happen. In the case of my PenguinTutor web site that is the changes in Linux and the Raspberry Pi over the last few years. In particular a new release of Raspbian was created last year (based on Debian Stretch) and the latest Raspberry Pi (Raspberry Pi 3B+) was released recently. I’ve now updated the Linux Tutorials and Raspberry Pi guides to reflect those changes. I’ve also taken the opportunity to add some new material including an overview of computer networking and a basic introduction to running Samba on the Raspberry Pi.

I’ve also added a photo of the latest version of the Raspberry Pi.
Raspberry Pi Model 3B+

I still need to review the LPI practice exams (I do try and review them fairly frequently, but it is due another revision) and as a historical record the blog pages won’t necessarily get updated (although I do sometimes add updates where necessary). But for now most of the pages should be up-to-date.

Raspberry Pi 6th Birthday – Birmingham Raspberry Jam 2018

March 3rd, 2018

Today is the weekend of the Raspberry Pi 6th Birthday. In the past the birthday has been celebrated with a large Raspberry Jam in Cambridge (organized by Mike Horne and Tim Richardson). I have been to the earlier birthday celebrations, supporting workshops run by others, giving presentations and running workshops.

For 2018 the birthday celebrations have been expanded to enable more people to take part with over 100 Raspberry Jams around the world. The nearest to me is the West Midlands Raspberry Jam at Birmingham which is organized by Tim Wilson and Spencer Organ. I volunteered to give a short talk and run two workshops at the event.

Unfortunately due to a large amount of snow and safety concerns the event has had to be postponed. The event will hopefully be rescheduled in a few weeks time.

In the meantime I thought I would still make my presentation and worksheets available as planned during the weekend. I still plan to give run these when the Birmingham Raspberry Jam can be rescheduled, but they may be useful in the meantime.

Creating Games on the Raspberry Pi – Space Asteroids

The talk and workshops are all on creating a game for the Raspberry Pi, from creating your own sprites to coding in Scratch or Python Pygame Zero and adding a controller using simple electronics.

The game is a cross between Space Invaders and Asteroids. All the sprites are created from scratch and programmed to interact with electronic button switches and an LED.

Talk on creating sprites using Blender

This is a short talk about what Blender is and how it can be used as a tool when looking to create computer games.

Raspberry Pi Birthday 2018 - Blender talk
Raspberry Pi Birthday 2018 – Presentation notes for talk on using Blender to create Sprites for computer games.

Workshop – Create Space Asteroids, physical computing computer game for Raspberry Pi – Scratch Version

This worksheet is created for a version of the Space Asteroids game that is created in Scratch 2 on the Raspberry Pi.

It’s designed for those young and old who have preferably done a bit of Scratch programming before, but want to take first steps in physical computing or designing an interactive game. It’s also suitable for complete beginners to Scratch, who may need some help to get started with using Scratch.

Space Asteroids physical computing game for the Raspberry Pi - Scratch version  2
Worksheet – Space Asteroids physical computing game for the Raspberry Pi – Scratch version 2

Workshop – Create Space Asteroids, physical computing computer game for Raspberry Pi – Python Pygame Zero version

This worksheet is created for a version of the Space Asteroids game that is created in Pygame Zero (Python 3) on the Raspberry Pi.

This is designed for older students and adults that have already done some programming in Python, but want to learn about designing games in pygame zero or how to connect to simple electronics using gpio zero.

Space Asteroids physical computing game for the Raspberry Pi - Pygame Zero and GPIO Zero (Python 3)
Worksheet – Space Asteroids physical computing game for the Raspberry Pi – Pygame Zero and GPIO Zero (Python 3)

World Book Day – Raspberry Pi and Pimoroni InkyPHat Badge

March 1st, 2018

Today is World Book Day. For the last few years I’ve been supporting my local school by helping run their book sale. Last year I dressed up as The Wizard of Oz complete with Wearable Electronic flashing bow tie. This year I am a little more subtle as I won’t be wearing a full costume, but still keeping with the wearable electronics I’ve gone for a Raspberry Pi powered electronic badge.

InkyPHat wearable Raspberry Pi badge for World Book Day

The badge is based around a Raspberry Pi Zero W, mounted in a Pimoroni PiBow case and a InkyPHat display. The display is based around ePaper / eInk technology (similar to how the original Kindle works). This means it uses very little power and will continue to display the output even after the power is switched off. It does have a bit of a flicker when it refreshes the screen (which takes a few cycles to update), but that only draws attention to the badge. Unlike most other ePaper displays this one can display more than one colour. It can display images in Red, Black and White (although one of these is likely to be the background colour).

You can see the badge in action on the short video below:

I’ve also included the source code of the program, for this you will also need a png file which needs to be created using a 3 colour palette (more details of how to create an Inky Phat compatible image are provided here).

Source code for Raspberry Pi InkyPHat World Book Day badge

#!/usr/bin/env python

import inkyphat
import time
from PIL import ImageFont, Image

font = ImageFont.truetype(inkyphat.fonts.FredokaOne, 32)

message = ""
w, h = font.getsize(message)
x = (inkyphat.WIDTH / 2) - (w / 2)
y = (inkyphat.HEIGHT / 2) - (h / 2)

font2 = ImageFont.truetype(inkyphat.fonts.FredokaOne, 28)
message2 = "Books are\nFun!"

w2,h2 = font.getsize(message)
x2 = (inkyphat.WIDTH / 2) - (w2 / 2)
y2 = (inkyphat.HEIGHT / 2) - (h2)

while 1:
inkyphat.text((x, y), message, inkyphat.RED, font)


inkyphat.text((x2, y2), message2, inkyphat.BLACK, font)

The image file is below:

World book day InkyPHat image

ESA European Astro Pi Project – Mission Zero – Code that ran on the International Space Station

February 15th, 2018

The ESA European Astro Pi Project – “Mission Zero”, involved school children creating code that actually ran on the International Space Station (ISS).

My son joined with a friend (both aged 9 at the time it was submitted) to create a Python program that ran on the International Space station during February 2018.

Here’s his story:

The AstroPi shown in the video is a 3D printed replica of the Raspberry Pi case that is installed on the Space Station. It includes the Raspberry Pi Sense hat which shows the LED display and includes the temperature sensor.

The project gives a friendly greeting to the astronauts and then displays the temperature in degrees Celsius. If the temperature is warm then it displays a warm picture showing the sun and a smily face, or if it is cold then it displays a snowy scene.

The code has been written in Python. There were some slight modifications used in the video (it included key-presses that allowed the code to be repeated), but the actual code that ran on the Raspberry Pi on the ISS is included below:

from sense_hat import SenseHat
import time
sense = SenseHat()

red=(255, 0, 0)

blue=(10, 0, 255)
sense.show_message("Hello, Astronauts", text_colour=red, scroll_speed=0.05)

sense.show_message("Have a nice day", text_colour=(0, 0, 255), scroll_speed=0.05)

temp = sense.get_temperature()

temp = round(sense.get_temperature(), 1)


sense.show_message("It is " + str(temp) + "Degrees", text_colour=(0, 255, 0), scroll_speed=0.05)

g = (0, 255, 0)
b = (0, 0, 255)
w = (255, 255, 255)
y = (255, 255, 0)
g = (0, 255, 0)
p = (145, 200, 255)

hot = [
  w, w, w, w, w, y, y, y,
  w, b, w, b, w, y, y, y,
  w, b, w, b, w, y, y, y,
  b, w, w, w, b, w, w, w,
  b, w, w, w, b, w, w, w,
  w, b, b, b, w, w, w, w,
  g, g, g, g, g, g, g, g,
  g, g, g, g, g, g, g, g

cold = [
  p, p, p, p, p, p, p, p,
  p, p, p, p, p, w, p, p,
  p, p, p, w, p, p, p, p,
  p, p, w, p, p, p, p, p,
  p, p, p, p, p, w, p, p,
  p, p, p, p, p, p, p, p,
  w, w, w, w, w, w, w, w,
  w, w, w, w, w, w, w, w

if temp >= 20:

The children actually wrote more code initially, but it had to be trimmed down to make it simpler due to the restrictions on the project.

Below are some photos of my son with his certificate and of the 2nd page of the certificate showing that the ISS was in orbit above Columbia at the time the code was run.

European Astro Pi Mission Zero certificate - code that was run on the International Space Station (ISS)

Certificate from European Astro Pi Mission Zero project, showing where the ISS was when running the code

OMSCS Studying online – MSc in Computer Science with Georgia Tech

January 24th, 2018

I’ve recently completed an online Master degree with Georgia Tech. This has been a huge commitment in terms of time, but I’ve learned a lot.

Online MSc in Computer Science OMSCS at Georgia Tech

“University Master Degree – same as on-campus but it’s online”

As an online course the cost is only a fraction of on-campus classes, and in my case my employer covered the course fees. The classes are taken at a time that suits the student by following videos online and submitting projects and homework through an online portal. It even replicates the exam environment taking exams with the student monitored by webcam. The final degree certificate is the same as the on-campus degree.

Other than the cost and flexibility of working online the course is the same as those taught at the University so it is not easier or harder than an on-campus course, although it does have some different challenges.

The classes are provides as online videos through Udacity. These are mainly traditional style lecturer and slides, but some include added videos to show real-world examples. Some also include knowledge check quizzes during the classes so that you can check on your learning. These can be watched and re-watched as much as is required and don’t need to follow the pace of the class (although it’s usually a good idea to keep up with the videos). The assessment is then performed based on homework tasks, projects and/or exams. Support is provided to the students through forums (both students-helping-students and with Teaching Assistants supporting the students) and Virtual meetings with the TAs and/or Professor.

There are a few different specializations available and a reasonable amount of choice of classes within them, although some classes are compulsory (such as all specializations needing a theory class). There are around 29 classes at my last count, with more new classes being added each year.

“You don’t need a computing degree, but computing experience and maths knowledge is required”

I was a little concerned about my lack of knowledge when starting the Master degree. Whilst I already have a Master degree it is in electronics rather than computing and whilst I have had plenty of hands-on with computing and programming I did think I may be missing some of the theoretical knowledge around Algorithms. My theoretical maths is also a bit rusty as it is almost 20 years since my first degree. I therefore spent some time reading up on Algorithms prior to starting the course as well as trying to brush-up some of my maths. This paid off as I did well on the theoretical class and got a comfortable B, although not as good as the A I got on the other classes.

I do think it would be advantageous to have studied for a Bachelors level computing degree, it wasn’t necessary with the appropriate experience.

Classes I studied

I chose the specialization of computing systems, which is a fairly generic specialization focussing on operating systems, programming and security.
Below are the courses I took along with a short summary and example of the projects:

CS6250 Computer Networks

An advanced networking course looking at Software Defined Networking. Fortunately I had plenty of experience with computer networking so this was a good starting point, although the detail of Software Defined Networking was new.

This was project and homework based including monitoring and tuning network performance and creating a firewall using Software Defined Networking.

MSc CS6250 project network performance graph

CS6300 Software Development Process

This is a class I was particularly interested to take as whilst I have had a lot of programming experience this has mostly been self-taught and I wanted to understand some of the theory of how to program better. The class didn’t disappoint me and I learnt and awful lot from this one.

The course was project and homework based, mainly using Java and Android programming, which I enjoyed. This included a project for an Electronic Point of Sale system that had to integrate with a (fictional) credit card machine.

UML Diagram created for CS6300 software development process project 2

CS8803-002 Graduate Introduction to Operating Systems (now CS6200)

I’ve always been interested in operating systems and coding close to the hardware. This was a difficult course and had some complex projects based around C programming. It was particularly difficult through a couple of the projects, but it was very worthwhile and I have a much better understanding of programming and how it interacts with the hardware and the operating system.

The projects included writing a file cacheing proxy server in C.

There were also difficult exams as well as the course work.

The word introduction makes this sound like it would be an easier course, but it was just as hard as the advanced operating systems class.

TCP Dump from project 3 of OMSCS Introduction to Operating Systems

CS6210 Advanced Operating Systems

Although the previous class was an “introduction” and this was titled advanced it was on a similar level. The one thing being that it did need some of the knowledge from the previous course. This class included projects using C programming, including parallel processing and synchronisation, as well as exams.

OMSCS CS6210 Advanced Operating System - memory page file homework

CS8803-o04 Embedded Software (now CS6291 Embedded Systems Optimization)

I thought that the name of this was deceiving and I’m glad to see it has now been renamed. I was hoping for a class on writing programs to handle the special cases of programming on embedded systems, but it turned out to be more a course on compiler optimizations. Although it did cover some of the challenges of designing embedded systems including realtime programming, the projects were based around how changes in the compiler and code could result in faster code.

This did use a Raspberry Pi in one of the projects.

Online MSc CS8803 Embedded Software optimizations

CS6035 Introduction to Information Security

Another class that I particularly enjoyed, partly due to my past experience working in IT security, but also because it involved some fun projects. This was still very complex as it involved a required a knowledge of how the computer and operating system worked (so it was good to have taken the operating system courses first). The projects were challenging, but I found rewarding. It included creating a buffer overflow to break into a system, but also how to defend against such attacks.

There was also an online exam.

MSc Computer Science - Introduction to Information Security - Cracking the payroll system

CS6505 Computability, Algorithms & Complexity

This is the hardest class that I took. It required a high level of maths knowledge as well as an understanding of algorithms. The class was completely exam based. I spent a lot of time studying on the course and learned quite a lot, but would have preferred a more practical course on the use of algorithms rather than analysing the computability and complexity. The assessment was exam based, including several exams which had to be handwritten and then scanned into the computer.

This class is compulsory for a number of specialisations including Computing Systems. I received a comfortable pass grade in the end, but I know some other students that dropped the class or didn’t get the pass they needed.

This class is no longer taught having been replaced by a Graduate Algorithms course, which is aimed at making the class more relevant and hopefully improving the pass rate.

Exam from CS6505 algorithms - command and conquer

CS6310 Software Architecture and Design

Like the software development class this is something I was particularly interested in. There were some challenges due to working in teams (which was also the case with the software development class), which was made particularly difficult do to there being a large number of assignments which needed to be completed within a short period of time but these challenges were overcome.

The final project was a class management system application, written in Java using a MySQL database and including Weka Analysis.

GUI Mockup for project for CS6310 Software Architecture and Design

CS6262 Network Security

This is another class that I looked forward to and it was another enjoyable class. It involved looking at possible attacks and defences relating to network based attacks including network scanning, web browser exploits (XSS and Click Jacking) and malware analysis.

It was all project based, some of which I really enjoyed.

Click Jacking example from network security class CS6262 from Georgia Tech OMSCS

CS8803-O07 Cyber-Physical Systems Security

My final Class was Cyber-Physical Systems Security. This class was is mainly about security surrounding electrical systems, but also covered other utilities. It had a number of mini-projects, which were fairly easy and took much less time than the other classes, but also had a difficult exam. Still an interesting class, but not so much as the other security related classes.

Searching the Internet for Webcams - Cyber Physical Systems CS8803 Georgia Tech

“Studying online for a degree introduces some challenges, but also adds many benefits”

With the course being online then there were a number of advantages, such as being able to take the course at a time that suits you and being able to re-watch the lectures, but there were a number of challenges that it introduced.

I took the degree course alongside my full time job and family life as a parent of two children. This meant that a large proportion of my spare time was spent on the course. I tried to do most of the studying during the weekday evenings so that I could spend the weekends with my family, but this didn’t work so well with the team projects.

Whilst it is possible to take multiple classes most students I know took just one or two classes at a time. In my case taking only one class at a time meant that it took 10 terms which is about 3½ years to complete.

“Time zone can add additional challenge, but so too can other responsibilities”

I live in the UK, but Georgia Tech is a University in the USA, with most students being from the US. With a 5 to 8 hour time difference this added some additional challenges around timing. These were overcome, with some flexibility on my behalf as well as my family. For example I sometimes stayed up late (up to the early hours of the morning) to attend an online Office Hour with a TA and would schedule team meetings in my late evening to co-inside with early evening of team mates during the group projects. It was also a problem where virtual meetings would occur during my children’s bedtime, so I would have to try and put them to bed before or after the meetings.

The harder challenge when working in a team was that I preferred to avoid working weekends to spend time with my family, whereas other students would dedicate their weekends to their studies. In this case I would try and contribute towards the project during the week, but would inevitably also end up having to spend time on Hangouts or Skype calls during the weekends, which is one of the sacrifices I had to make.

Like other courses there are sometimes those that will seek to cheat to improve their score, or to avoid doing the set homework. This is a real shame as it could potentially damage the reputation of those that do work honestly. Fortunately there are steps in place and we do hear of people being identified and having their score reset or otherwise punished to prevent this from being a problem.

You may think that being an online course then it would be more open to cheating, but there are checks in place to prevent cheating. This includes AI cheat detection during exams (with manual verification) and checking submitted code for plagiarism. There are ways that students could still attempt to cheat, but this is no different from other courses and it doesn’t appear to be a major problem.

“Some of the classes did have teething troubles”

There were a few issues with classes in particular some assignments. Some of these were technical issues due to the classes being so new (in some cases I was taking the class during it’s first run on the online MSc program). These included problems with the Virtual Machines (most of the project work was in Linux Virtual Machines) or problems with the supplied code. Most of the technical problems were fixed by the students working together. These were a good learning opportunity, although perhaps not directly relevant to the topic at the time.

The other problems that I encountered were due to ambiguities in the assignment instructions. These were usually clarified prior to the due date, but did sometimes result in having to redo parts of the assignment which felt like a waste of time when there was a deadline running.

“How did I do”

In the end I managed to get an A in 9 out of the 10 classes, and a B in one. The US often use a GPA scoure which I achieved 3.9 and as a comparison with a UK that would be the equivalent of a distinction. I am very happy with my achievement which reflects the amount of work that I put into it. It is a difficult course, which I believe is important to maintain the high standard.

There was an option to attend the full graduation ceremony at Georgia Tech. Due to a combination of logistics and the cost of travel from the UK I made the difficult decision not to attend the ceremony. I was a little disappointed by this as it does feel a bit of an anti-climax after all the effort, but I am now eagerly waiting on receiving the certificate when I will take the opportunity to celebrate with my family instead.


It’s been a great journey. There have been highs with some fun projects and learning great new stuff, but also some low points when I’ve had a deadline to meet or being revising for an exam. In these ways then this is the same way as any University course and the final grade does reflect that. This has been a very difficult course, but in comparison to my previous Master degree I found the long and slow approach useful (taking one class per term) as it meant that I only had to focus on that one subject at a time.

For anyone considering taking a degree like this then you do need to think carefully about how much time you are willing to put in. In my case the impact was not just on me, but also on my family. Fortunately they were supportive of me spending time on my course.

For more details about the course then see the link below:

Note: The images in this post are intentionally small to prevent them from being used by future students, which would be a breach of the Georgia Tech plagiarism rules.

The power of open source – Creating a GUI with Python and guizero

January 13th, 2018

This isn’t going to be a guide about how to program a GUI (graphical user interfaces) using guizero (hopefully I’ll add some instruction on that in future), but it does explain which I chose guizero, some of the concepts I used and a bit of an insight into this open source software library.

Adding GUIs was too hard – until now …

The story starts about a month ago, when I decided that I wanted to add a GUI to my Network Quiz Challenge. I actually wanted to add a GUI a year ago, but decided it would take too long back then and it got pushed to the back-burning until now. I already had most of the code in place (it involves a Raspberry Pi running Python talking to a Arduino using PySerial), but it was command line only.

I have some experience of writing code for graphical user interfaces on a variety of platforms, but generally it is the most difficult and time consuming part of any programming project. For anyone that is starting out in programming it can also be an incredibly steep learning curve just trying to get started in GUI programming. I have created a program before using Python and tkinter (which is the default GUI library for Python) but the code created is quite complex – see NeoPixel GUI for Raspberry Pi.

Networking challenge - with guizero GUI

After looking around a bit I came across a couple of Python libraries that are trying to make the experience of learning a GUI easier, and in the end I settled on guizero. It’s mission “The aim of guizero is to make the process of creating simple GUIs quick, accessible and understandable for children.”

Contributing to the Python guizero library

I started work on the GUI version, but came across a couple of issues. One is that there was a bug in the provided example code which had the x and y values the wrong way around, which I was able to work through and submit the correct details back to the maintainers. The second issue was due to a lack of column and rowspan feature in the grid layout. The grid layout arranges the widgets into a grid going across and down. This is best visualized by thinking about a spreadsheet. If you wanted a header to go across multiple columns in a spreadsheet then you would merge multiple cells together, this is the same using grid layout where columnspan merges them horizontally and rowspan vertically. This is something that tkinter supports (which guizero uses behind the scenes), but because it needed to be configured when creating the widgets it was not possible to use this except by updating the guizero library. I raised this on the GitHub issues page. Fortunately guizero is under active development at the moment so I got a response straight away. We discussed different ways of implementing it and I was able to contribute the code to add that feature. I also updated the document showing an example of how the gridlayout can be used to arrange photos as shown below, which is something that was not possible using the grid layout before.

Python guizero, images with columnspan and rowspan

The code is now in the main code so can be used by anyone else. This is an example of how open source code can benefit the wider community as the things that I implemented for my own requirement will benefit others, in the same way that I was able to build on code that others had done (after all guizero would not exist at all without the contributions of others).

Creating the GUI for the quiz

I only had a short time to create the GUI, as it was needed for January I didn’t start until after I’ve finished studying for my Master’s degree in the December. This was also through the Christmas period where I’ve been incredibly busy with my family and other volunteer activities. So I didn’t have much time to explore different ways of creating the GUI and fell back onto an old tried and tested hack of using almost invisible images to set the column widths. This is an old technique that used to be popular with websites before we had CSS.

It’s a bit of a hack, but it did the job. I may look at alternatives in future which may work better, but as far as a usable GUI it worked well. For this reason I probably won’t be using this code as a teaching example, it’s also quite complicated for learning from as I have used object orientation throughout the code (something that I think is good, but perhaps a bit advanced for the kids that guizero is primarily aimed at). You can see an example of how it looks in the screenshot below. I think it looks OK, not as good as some applications, but considering it was done in a short timeframe then all the main functionality is there.

Screenshot of networking quiz running on Raspberry Pi / Arduino

Another “cheat” is that the speedometer shown in the screenshot above is actually a static image. I created three different images and an appropriate one is shown depending upon the score.

Using guizero and tkinter side by side

One other thing that I needed to do was to use some native tkinter widgets as well as those through guizero. In particular I wanted a File Open dialog, but that is not yet implemented. This is one of the flexibilities of guizero in that in some cases even where something is not yet implemented in guizero it’s possible to just call the tkinter code directly.

Contributing to open source software

Although almost all the code that I write is open source it is normally something I write for myself, either to meet a requirement that I have or as a way to learn something new. I have contributed to some other projects, but as with my contribution to guizero that has been only fairly small. Much of this is due to time as it can take a long time to get familiar with existing code to the point where you can provide a bigger contribution. Much of my time is spent on my family, other volunteer activities (including Scouting and STEM Ambassador), my personal projects (writing and programming) and until recently studying for another Master’s degree.

I’ve now completed my degree so I do have a little more time available, so I would like to contribute more to
a more established project, but I’m not sure what yet. I do think that these GUI frameworks are useful including guizero and pygamezero (similar concept but for creating games rather than regular applications).

It can be difficult when there is already an active team developing the code and you don’t want to get in the way of other development. In this case there was different ways that the span could be implemented, so I was able to discuss it with the existing developers first so that it was consistent with their ideas as well.


This post is more about the advantages of open source software. Open Source software benefits from the collective contributions of many people and it can bring additional rewards in knowing that you helped someone else. The fact that I could update the library in time to complete my project was much better than if this was closed source.

So if you see an opportunity to fix some code then take a look at how you can help.

Upgraded Networking Challenge for Computing fair

January 12th, 2018

I have written previously about a school computing fair that I helped support. I went along again this year as a way to promote STEM and in particular computing. As I work for a telecommunications company then I wanted to promote computer networking as a career option. I didn’t want to just talk about computer networking as I much prefer something that is more hands-on. I therefore created the networking challenge quiz, which involves a multiple choice quiz which is answered by wiring up the appropriate ports between two patch-panels. If they got the answer correct then it lights up green, get it wrong and it lights up red.

Without having lots of network switches I simulated the networking using an Arduino. I then connected a Raspberry Pi which could tell check the status of the Arduino pins and tell it to update the colour of the LEDs. The old post about this is available: Networking challenge quiz (CLI version)

This worked well, but this year I wanted to improve on it. In the past the pupils had to read the answers from printed paper, so this time I instead provided this through a graphical user interface (GUI) running on a Raspberry Pi, which also allowed me to add pictures associated with each question. Also in addition to lighting up the results on the patch-panel, the GUI showed a speedometer like image showing them how well they did.

Screenshot of networking quiz running on Raspberry Pi / Arduino

This was written using Python and guizero (but I’ll talk about those in more details in a future post).

The quiz worked really well, backed up by one pupil that said it was “great!” and clearly enjoyed taking part.

Most of the questions were ones that I had aimed at the appropriate age group (as an overview of computer networking is included in the school curriculum) and I also included subtle hints in the images. I thought that the scores were a little low (as I wanted the pupils to walk away thinking they had done well) and perhaps they were a little too subtle for some, so during the day I decided to make it a little easier and tweaked a couple of the questions. This is something that I wasn’t able to do last year when the questions were pre-printed, but with the new version it was just a couple of quick changes to the json quiz files. There was one question that was intentionally difficult to challenge those that know lots about computers, which relates to the change from IPV4 to IPV6, I’m pleased to say 4 pupils knew the answer to that question and a few more guessed the correct answer.

At the end I explained that whilst the quiz involved a lot of acronyms and that to the outsider computer networking sounds like a foreign language, that when working in the industry these acronyms do become second nature and so not to be scared off by them.

Networking challenge - with guizero GUI

I’ve made all the code available via GitHub, although it’s really just for this project it may be of use to others.
Penguintutor Github – networking quiz

Twitter Status - follow stewartwatkiss

UK days out, children and holiday information is also available on the Days Out Diary web site
Linux, LPI and the Quiz / Test Program posts are also available on the Penguin Tutor website
First Aid Information, first aid games and first aid practice test / quiz entries are also available on the First Aid Quiz Web site