www.main.lv
Don't think just code it

2009-08-23 Python PyGame Tutorial Event System

Now you can set application window. But there is one problem you have to terminate application by killing.
Adding event handling help us exit from application by clicking close button or pressing some other button.
for event in pygame.event.get():
if event.type == pygame.QUIT:
    runing = False

Now you can exit from application by clicking close button.
Event types
There are defined other event types pygame.(KEYUP, KEYDOWN, MOUSEMOTION, MOUSEBUTTONP, MOUSEBUTTONDOWN, VIDEORESIZE). All of these events described in pygame documentation
Tutorial source