"Brent W. Hughes" <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> I'm just starting to learn pygame.  I write what I think is just about
> the simplest program that should display a window and then quit.
> #-----------------------------------------------
> import sys
> import time
> import pygame
> 
> pygame.init()
> screen = pygame.display.set_mode((640,480))
> pygame.display.set_caption("A Bug's Life")
> time.sleep(4)
> #-----------------------------------------------

Two problems here - first is that you should always call 
pygame.display.quit() when done. The second is that if you sleep(4) 
you've effectively blocked off the event loop for that process, which 
makes Windows unhappy. Even clicking 'close' to close the window won't 
work. Your very dumbest pygame program should have a loop like:

        while pygame.event.poll().type != KEYDOWN:
                pygame.time.delay(10)

Which just does nothing (but pumps the event loop) until a key is 
pressed, then exits.

Or you could add up the spent time and bail when it hits four seconds, or 
whatever you want, but you should be doing something with the 
pygame.event loop. And then call the pygame.display.quit() when done of 
course.


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to