2015-02-08 4 views
0

Я новичок в разработке графики Python. Я пытаюсь запустить приведенный ниже код, но это дает странную ошибку. Может кто-нибудь помочь мне с этой ошибкой?неожиданный аргумент ключевого слова, 'текст'

from livewires import games, color 
SCREEN_WIDTH=640 
SCREEN_HEIGHT=480 
my_screen=games.Screen(SCREEN_WIDTH,SCREEN_HEIGHT) 
wall_image=games.load_image("wall.jpg", transparent=False) 
my_screen.set_background(wall_image) 
games.Text(screen=my_screen, x=500, y=30, 
      text="Score: 1756521", size=50, 
      colour=color.black) 
my_screen.mainloop() 

и на выполнение этого я получаю ошибку ниже:

Exception NameError: "global name 'screen' is not defined" in <bound method Text.__del__ of <livewires.games.Text object at 0x02B14810>> ignored 
Traceback (most recent call last): 
    File "C:\Python31\game_test.py", line 9, in <module> 
    colour=color.black) 
TypeError: __init__() got an unexpected keyword argument 'text' 

В самом деле, я смотрел на исходный код livewires games.py модуля и ниже

class Text(Object, ColourMixin): 
    """ 
    A class for representing text on the screen. 

    The reference point of a Text object is the centre of its bounding box. 
    """ 

    def __init__(self, screen, x, y, text, size, colour, static=0): 
     self.init_text (screen, x, y, text, size, colour, static) 
     ......... 

Итак, где я иду не так ???

+0

Livewires ужасно. Он просто ограничивает функциональность Pygame, поскольку Pygame ограничивает функциональность SDL. В лучшем случае я говорю палку с Pygame. –

ответ

0

from livewires import games, color

Нет такой модуль color, но colour [proof link]

"C:\Python31\game_test.py"

Пожалуйста, прочтите модуль docs. Я не думаю, что он поддерживает python3.

The package has been used on versions of Python from 1.5.2 to 2.4, but the games module now uses PyGame which requires at least version 2.1. Release 2.1 experienced some compatibility problems with Python 2.3 and later (or more specifically Tk8.4 which those include) which are hopefully corrected by this revision.

Смежные вопросы