我最近在学校PC上下载了Pygame(我以前有经验),但是当我尝试打开窗口时,它不起作用,即使我在窗口中涂了颜色,也是黑色的代码。
我什至复制了此代码:
import pygame
background_colour = (255,255,255)
(width, height) = (300, 200)
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Tutorial 1')
screen.fill(background_colour)
pygame.display.flip()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
但是它做同样的事情。
额外:
我将Spyder与Python 3.6
预先感谢:)
您的代码在我的Mac中工作。如果您在Windows中,请尝试重新启动PC。另外,尝试从命令行执行示例。