There's more...

We previously created the Photo class. Now we can add some test code to our module to ensure that it functions as we expect. We can use the __name__ ="__main__" attribute as before to detect whether the module has been run directly or not.

We can add the subsequent section of code at the end of the photohandler.py script to produce the following test application, which looks as follows:

The Photo View Demo application

Add the following code at the end of photohandler.py:

#Module test code def dispPreview(aPhoto): """Create a test GUI""" import tkinter as TK #Define the app window app = TK.Tk() app.title("Photo View Demo") #Define ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.