Reputation: 17
envface1=pygame.image.load(p1)
envface2=pygame.image.load(p2)
envface1=pygame.transform.scale(envface1,(768,400))
envface2=pygame.transform.scale(envface2,(768,400))
start = timeit.default_timer()
window.blit(txt[0],(0,0))
window.blit(envface1,(0,400))
window.blit(envface2,(800,400))
pygame.display.flip()
display=False
while not display:
#delete the print will make it no responding
print
keys=pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
display=True
print "1"
if keys[pygame.K_RIGHT]:
display=True
print "2"
end=timeit.default_timer()
print end-start
pygame.quit()
For this part of code, I am trying to make something that user can choose the picture they like and print the result out. But in the while loop, when I delete the line with "print" only and run it, the program will down and make it no responding. Why would this happen?
Upvotes: 0
Views: 38
Reputation: 8422
As Cyber explained, you have a while loop that runs while display
is false. However, since you don't modify display
at all inside the loop, you've effectively created an infinite loop.
Your observation that the program will not respond is caused by the fact that nothing happens in the infinite loop unless a key is pressed.
Upvotes: 1