python – 几秒后Pygame窗口没有响应

几秒钟后(大约5秒),这段简单的代码崩溃(窗口没有响应).

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((640, 480), 0, 24)
#clock = pygame.time.Clock()

#font = pygame.font.Font(None, 32)

cycles = 0
while True:
    screen.fill(0)
#    text = font.render('Cycles : %d' % cycles, True, (255, 255, 255))
#    screen.blit(text, (100, 100))

    cycles += 1

    pygame.display.update()

如果我取消注释注释行,我可以清楚地看到程序在显示47到50之间的值时失控.

我使用python 2.7和pygame 1.9.2,Windows 8(64位)和Eclipse PyDev.

在while循环的开头调用pygame.event.get().
https://stackoverflow.com/questions/20165492/pygame-window-not-responding-after-a-few-seconds

转载注明原文:python – 几秒后Pygame窗口没有响应