Closing Pygame Window

前端 未结 8 758
不知归路
不知归路 2020-12-31 03:24

I just spent a fair amount of time finding a 64-bit installation of pygame to use with python 3.3, (here) and now am trying to make a window. However, although the window op

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 04:04

    if you want to make pygame close when window button x is pressed, put the code like this:

    from sys import exit
    while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    exit()
    

    We put exit() after pygame.quit(), because pygame.quit() makes the system exit and exit() closes that window.

提交回复
热议问题