PyCharm不开Pygame风

2024-04-18 13:28:42 发布

您现在位置:Python中文网/ 问答频道 /正文

当我在PyCharm中运行此代码时,它不会打开窗口。python启动程序可以运行,但不能运行pygame。当我把它作为一个.py文件运行时,它工作得很好。你知道吗

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

Tags: 文件代码py程序eventdisplaywidthscreen