Here's a quick python sample code using pyglet:
import pyglet
window = pyglet.window.Window()
image = pyglet.resource.image('kitten.jpg')
@window.event
def on_draw():
window.clear()
image.blit(0, 0)
pyglet.app.run()
I understand that @window.event
is a decorator and the function on_draw()
is modified by it. What I don't understand is how running pyglet.app.run()
knows about this new draw function, so it can run it.