Closing Pygame Window

前端 未结 8 756
不知归路
不知归路 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条回答
  •  旧时难觅i
    2020-12-31 03:54

    To answer the original question: You must call pygame.quit() after breaking the main loop. One elegant solution goes as follows:

    def run():
        pygame.init()
        while True:
            # ...
            for event in pygame.event.get():
                # Handle other events
                if event.type == pygame.QUIT:
                    return pygame.quit()
    

提交回复
热议问题