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()
A pygame window can be closed properly if you use a different python interpreter. Try using pycharm, you can close pygame windows using pycharm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With