Sunday, 15 September 2013

How to close window using [x] in corner without it freezing?

How to close window using [x] in corner without it freezing?

I want to click the [x] in the corner of the window and for it to shut the
whole application. Instead it is freezing up and not responding. Thanks
for any help.
import sys
#import and init pygame
import pygame
pygame.init()
#create the screen
window = pygame.display.set_mode((640, 480))
#draw a line - see http://www.pygame.org/docs/ref/draw.html for more
pygame.draw.line(window, (255, 255, 255), (0, 0), (30, 50))
#draw it to the screen
pygame.display.flip()
#input handling (somewhat boilerplate code):
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit(0)
else:
print event
I'm used to java and so was wondering if there was a dispose and close
type action for the frame.

No comments:

Post a Comment