2017-08-05 51 views
2

我已经在python 3.5.3上使用programarcadegames.com上的说明安装了pygame 1.9.4版。当我使用pygame绘制线条和形状时,它很好,但是当我尝试使用pygame.font.SysFont时,pygame不再响应。例如,当我运行下面的代码无响应pygame的窗口会显示:Pygame在试图在macOS上显示文本时未响应Sierra

 

import pygame 

pygame.init() 

BLACK = (0, 0, 0) 
WHITE = (255, 255, 255) 

size = (400, 500) 
screen = pygame.display.set_mode(size) 

done = False 
clock = pygame.time.Clock() 

while not done: 

    for event in pygame.event.get(): # User did something 
     if event.type == pygame.QUIT: # If user clicked close 
      done = True # Flag that we are done so we exit this loop 

    screen.fill(WHITE) 

    font = pygame.font.SysFont(None, 25, True, False) 

    text = font.render("Some Text", True, BLACK) 
    screen.blit(text, [0, 0]) 

    pygame.display.flip() 
    clock.tick(60) 

pygame.quit() 

+0

只是尝试'font = pygame.font.SysFont(None,25,True,False)',也许它没有找到Calibri – PRMoureu

+0

@PRMoureu谢谢,但那不起作用。 – Dandelion

+0

你如何运行这个程序? ---可能与问题无关,但更好的定义while循环上面的字体(这一行:'font = pygame.font.SysFont(None,25,True,False)')。 – skrx

回答

1

更换font = pygame.font.SysFont(None, 25, True, False)font = pygame.font.Font(None, 25)解决了这一问题,但目前还不清楚什么原因造成的。