[Tutor] [pygame] why does my window not close?

David ldl08 at gmx.net
Sat Aug 1 16:03:24 CEST 2009


Dear Tutors,

I have written a simple pygame program:

<code>
import pygame, sys
pygame.init()
screen = pygame.display.set_mode([640, 480])
screen.fill([255,255,255,255])
pygame.draw.circle(screen, [0,255,0], [150,200,], 30, 0)
my_rect = (250, 150, 300, 200)
pygame.draw.rect(screen, [0,0,255], my_rect, 0)
pygame.display.flip()
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
</code>

I am using Ubuntu Jaunty, Python 2.6.2:

When I try to quit the program (clicking on the windows' [X] button),
nothing happens.
When I press CTRL-C on the Python interpreter, triggering a
KeyboardInterrupt, the windows' content vanishes (turns black), but the
window itself remains and can't be killed except by killing the Python
interpreter from which I started my program.
What is going on? I obviously want the window to disappear once I hit
the [X] button!

Cheers for a hint,

David


More information about the Tutor mailing list