1

Originally after I did some searching here, I found a question with the exact same problem I had: Pygame window not responding after a few seconds . I reviewed all the answers and tried them, but none of them worked. I tried using for loops to loop through every single event;

run = True
while run:
for event in pygame.event.get():
   if event == pygame.QUIT()
       run = False

But the window still closed. I also tried:

run = True
while run:
    event = pygame.event.get()
    if event == pygame.QUIT():
        run = False

Which had the same results as the one above. Can anyone help? Edit: I use PyCharm and MacOS Catalina.

Jeffrey Lan
  • 90
  • 13

1 Answers1

3

pygame.QUIT is a constante, but pygame.QUIT() is a call statement. Remove the braces. Anyway, the condition won't work, because you have to compare the type attribute of the event to the event type constant (see pygame.event). Furthermore the : is missing at the end of the if-statement.

if event == pygame.QUIT()

if event.type == pygame.QUIT:

Furthermore the Indentation is not correct:

run = True
while run:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
Rabbid76
  • 202,892
  • 27
  • 131
  • 174