pygame窗口无法关闭

时间:2020-08-04 17:31:25

标签: python pygame window

我目前正在关注Eric Matthes的Python速成课程(第一版),并且正在尝试制作pygame程序。但是,我一直无法关闭pygame窗口,不幸的是,尝试this other post中提到的所有解决方案对我来说都没有用。 (我正在使用Python 3.7.6,Spider 4.1.4和pygame 1.9.6。)

我当前的代码如下: (我一开始关注这本书,但后来又对其进行了多次修改)

import sys

import pygame

def run_game():
    
    pygame.init()
    screen = pygame.display.set_mode((1200,800))

    pygame.display.set_caption("Alien Invasion")
    
    bg_color = (230, 230, 230)

    running = True
    
    while running:
        
        for event in pygame.event.get():
            
            if event.type == pygame.QUIT:
                
                running = False
                pygame.quit()
                sys.exit()
                
        screen.fill(bg_color)
        
        pygame.display.flip()
        
run_game() 

可能我有什么想念的地方吗?

任何帮助将不胜感激!

更新:

当我使用pygame时,Python总是进入“不响应”模式: enter image description here

1 个答案:

答案 0 :(得分:0)

这可能会帮助您:

steps:
- task: IISWebAppDeploymentOnMachineGroup@0
  displayName: 'IIS Web App Deploy'
  inputs:
    WebSiteName: '$(Parameters.WebsiteName)'
    TakeAppOfflineFlag: True
    XmlVariableSubstitution: True

我从这里获得了此解决方案:Closing Pygame Window