Quenn3000
Posts: 3
Joined: Tue Aug 06, 2019 4:38 pm

Pygame event type

Tue Aug 06, 2019 4:48 pm

I program with Mu in a raspberry pi 4 and i would like than my program delete my main window when the event type is QUIT. My program :

Code: Select all

# document principale du jeu ( main document of the game )
import pygame
import time
pygame.init()

continuer = True
while continuer:
	for event in pygame.event.get():
		if event.type == QUIT:
			continuer = False
pygame.quit()
# fin du programme ( en of program )
Sorry for my english fault but I’m french :?

User avatar
MrYsLab
Posts: 375
Joined: Mon Dec 15, 2014 7:14 pm
Location: Noo Joysey, USA

Re: Pygame event type

Tue Aug 06, 2019 9:57 pm

In the future, please use code tags to maintain formatting.

I am not sure this is what you tried to post or not, but the code definitely had some issues.

Code: Select all

import pygame


pygame.init()

continuer = True
while continuer:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            continuer = False
            pygame.quit()
]

Notice that the event_type is pygame.QUIT and not just QUIT.

For a full example of code that draws a window and quits properly, please look at this link: https://github.com/it2school/Projects/b ... acircle.py

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12254
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Pygame event type

Wed Aug 07, 2019 1:10 am

added code tags to the original post

Return to “Python”