From 5dfdf367b873708e7c4a207950c5a154c36af567 Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Wed, 27 May 2015 23:45:08 +0200 Subject: [PATCH] Mouseclick does now also take pictures --- photobooth.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/photobooth.py b/photobooth.py index d4b6d62..00416ef 100755 --- a/photobooth.py +++ b/photobooth.py @@ -113,7 +113,7 @@ class GUI_PyGame: def show_message(self, msg): # Choose font - font = pygame.font.Font(None, 36) + font = pygame.font.Font(None, 48) # Render text text = font.render(msg, 1, (10, 10, 10)) # Position and display text @@ -135,6 +135,7 @@ class GUI_PyGame: # Handle the event if event.type == pygame.QUIT: return elif event.type == pygame.KEYDOWN: handle_keypress(event.key) + elif event.type == pygame.MOUSEBUTTONDOWN: handle_mousebutton(event.button, event.pos) # Ignore all input that happened inbetween pygame.event.clear() @@ -216,6 +217,12 @@ def handle_keypress(key): elif key == ord('c'): take_picture() +def handle_mousebutton(key, pos): + """Implements the actions for the different mousebutton events""" + # Take a picture + if key == 1: + take_picture() + def handle_gpio_event(channel): """Implements the actions taken for a GPIO event""" if channel == gpio_trigger_channel: