Hello,
I've searched the documentation and this group, but I can't find an
answer to this problem; nevertheless, if this is a common question, I
apologise :-)
I'm trying to create an Engine object, which I'll use to marshall
application resources, and because I generally like OO design. As
such, I'd like my window to be a property of my Engine object, but
this seems to mean that I can't access the window.event decorator. It
is entirely possibly (indeed, likely) that this problem is related to
my shallow understanding of decorators :-)
The code is as follows:
import pyglet
class Engine(object):
def __init__(self):
# Open a window.
self.window = pyglet.window.Window()
self.window.clear()
# Game loop.
pyglet.app.run()
@self.window.event
def on_draw():
print "MONKEY!"
window.clear()
e = Engine()
... and the traceback it produces:
Traceback (most recent call last):
File "main.py", line 21, in <module>
class North(object):
File "main.py", line 67, in North
@self.window.event
NameError: name 'self' is not defined
Any help would be much appreciated.
--Jon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---