When I execute the following code, the KEYDOWN events are not captured. The desired result is to exit the loop on any key press. How can I make the code have the desired effect?
while slideshow:
clock.tick(30)
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
elif event.type == pygame.KEYDOWN: slideshow = False
scope.screen.blit(safimg, (0, 0))
for t in statsurfs:
scope.screen.blit(t, (fontline * lnum, fontcol))
lnum += 1
lnum = 5
for t in dynsurfs:
scope.screen.blit(t, (fontline * lnum, fontcol * 2 - t.get_width()))
lnum += 1
pygame.display.flip()
pygame.time.delay(wtime * 1000)
for i in imgfiles:
img = pygame.image.load(i).convert()
#img = pygame.transform.scale(img, scope.size)
scope.screen.blit(img,(0, 0))
pygame.display.flip()
pygame.time.delay(wtime * 1000)
Also, any tips on how to optimize the code would be greatly appreciated as I'm new to Python programming.