From 171a6f3ebfa01b1bebdeb5595512671f77877d1d Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Tue, 19 May 2015 00:09:26 +0200 Subject: [PATCH] Keypress is now detected only once --- photobooth.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/photobooth.py b/photobooth.py index 76517b7..50ab141 100755 --- a/photobooth.py +++ b/photobooth.py @@ -125,10 +125,6 @@ class GUI_PyGame: def mainloop(self, filename): while True: - # Check for events - for event in pygame.event.get(): - if event.type == pygame.QUIT: return - elif event.type == pygame.KEYDOWN: handle_keypress(event.key) # Clear display self.clear() # Show idle-picture and message @@ -136,6 +132,13 @@ class GUI_PyGame: self.show_message("Hit me!") # Render everything self.apply() + # Wait for event + event = pygame.event.wait() + # Handle the event + if event.type == pygame.QUIT: return + elif event.type == pygame.KEYDOWN: handle_keypress(event.key) + # Ignore all input that happened inbetween + pygame.event.clear() def teardown(self): pygame.quit()