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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.