-1

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.

1 Answers1

0

The @window.event runs functions based on certain events (like on_mouse_press, on_key_press, etc.), and the on_draw event is just triggered once every frame.