From 5fd4767a4935a5f2f940380852acda6e9c0742d2 Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Tue, 23 Jun 2015 23:02:46 +0200 Subject: [PATCH] Exception handling for show_picture --- gui.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gui.py b/gui.py index 2b6171d..bccfdb9 100644 --- a/gui.py +++ b/gui.py @@ -162,8 +162,11 @@ class GUI_PyGame: # Use window size if none given if size == (0,0): size = self.size - # Load image from file - image = pygame.image.load(filename) + try: + # Load image from file + image = pygame.image.load(filename) + except pygame.error as e: + print("ERROR: Can't open image '" + filename + "': " + e.message) # Extract image size and determine scaling image_size = image.get_rect().size image_scale = min([min(a,b)/b for a,b in zip(size, image_size)])