Closing Pygame Window

前端 未结 8 781
不知归路
不知归路 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:08

    Not sure but try this Because you code runs fine on my system after I add pygame.quit() at the end

    import pygame
    import time
    (width, height) = (300, 200)
    screen = pygame.display.set_mode((width, height))
    pygame.display.flip()
    pygame.display.set_caption("Hello World")
    running = True
    try:
        while running:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    running = False
        pygame.quit()
    except SystemExit:
        pygame.quit()
    

    Its perhaps because as Idle is made on Tkinter and thus Tkinter and Pygame main loop do not have a mutual understanding.
    Your code will run very well on command prompt though.

提交回复
热议问题