Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pygame window can not be closed on a Mac problem

I have made a python program that uses Pygame. For some reason, I can't close the window when pressing the red cross. I tried using Command+Q but it doesn't work as well. I have to quit idle (my python interpreter) to close the window. Is there any other way to make the window close by pressing the red 'x' at the top right-hand corner?

My code:

import pygame
import sys
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((800,800))
while 1:     
    pygame.display.update()
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
like image 763
Qiu YU Avatar asked Sep 17 '25 07:09

Qiu YU


1 Answers

A pygame window can be closed properly if you use a different python interpreter. Try using pycharm, you can close pygame windows using pycharm.

like image 69
Tigre Avatar answered Sep 19 '25 07:09

Tigre