我正在尝试在Raspberry Pi上初始化pygame,它需要键盘中断才能执行任何操作.这是我的代码:
os.putenv ( "SDL_VIDEODRIVER" , "fbcon" )
pygame.display.init() # It hangs here
screen = pygame.display.set_mode ( ( 1024 , 768 ) )
pygame.draw.rect ( screen , ( 0 , 255 , 0 ) , ( 15 , 15 , 15 , 15 ) )
pygame.display.flip()
keyLoop = True
while keyLoop:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_DOWN:
print ( "Down arrow pressed, exiting" )
keyLoop = False
pygame.quit()
Run Code Online (Sandbox Code Playgroud)
我在这里发现了一个类似的问题,Python程序在键盘中断之前不会响应,但它不会让我添加注释,我已经尝试了所有他们的建议但仍然有问题.如果我按CTRL + C然后我的图形出现,但键盘不起作用.
谢谢 …