2013-09-16 131 views
1

我試圖顯示消息隊列,但我不明白爲什麼我收到類型錯誤。'pygame.Surface'對象不可調用

下面的整個錯誤。

Traceback (most recent call last): 

** IDLE Internal Exception: 

File "C:\Python27\lib\idlelib\run.py", line 298, in runcode 
    exec code in self.locals 

File "C:\Documents and Settings\Mohammad Raza\Desktop\Python Scripts\messageQueue.py", line 28, in <module> 

screen.blit(font.render(text, True, (0,0,0)) (0, y)) 

TypeError: 'pygame.Surface' object is not callable 

代碼:

import pygame 
from pygame.locals import * 
from sys import exit 


pygame.init() 

SCREEN_SIZE = (800, 600) 
screen = pygame.display.set_mode(SCREEN_SIZE,0,32) 

font = pygame.font.SysFont("arial",16); 
font_height = font.get_linesize() 
event_text= [] 

while True: 

    event = pygame.event.wait() 
    event_text.append(str(event)) 
    event_text = event_text[-SCREEN_SIZE[1]/font_height:] 

    if event.type == QUIT: 
     exit() 

    screen.fill((255,255,255)) 

    y = SCREEN_SIZE[1]-font_height 
    for text in reversed(event_text): 
     screen.blit(font.render(text, True, (0,0,0)) (0, y)) 
     y -= font_height 


    pygame.display.update() 

回答

3

缺少逗號:

screen.blit(font.render(text, True, (0,0,0)), (0, y))