I am in MacOs and my Pygame window does not close

Viewed 22

Window Class

def __init__(self, window_dimension: tuple[int, int]):
        pygame.init()
        self.window = pygame.display.set_mode(window_dimension)
        self.running = True
def check_quit(self, event_type: int): 
        if event_type == pygame.quit:
            self.running = False

Main

WINDOW_DIMENSION = (600, 600)

win = Window(WINDOW_DIMENSION)

while win.running:
    for event in pygame.event.get():
        win.check_quit(event.type)

I don't get why this wouldn't work. I am in Mac.

1 Answers

pygame.quite() is a function that uninitializes all pygame modules and must be called after the application loop. The enumerated constant for the event type that occurs when the window is closed is pygame.QUIT (see event module):

if event_type == pygame.quit:

if event_type == pygame.QUIT:
Related