每个窗口都有自己的context,这里演示怎么配置context以及如何实现定时器......
#-*- coding:gbk -*- import pyglet platform=pyglet.window.get_platform() display=platform.get_default_display() screen=display.get_default_screen() template=pyglet.gl.Config(alpha_size=8) config=screen.get_best_config(template) context=config.create_context(None) window=pyglet.window.Window(context=context) image=pyglet.image.load('splash.png') sprite=pyglet.sprite.Sprite(image) sprite.dx=10.0 @window.event def on_draw(): """ draw the window and widget """ window.clear() sprite.draw() def update(dt): """ update every 1/60.0 seconds """ sprite.y+=sprite.dx*dt sprite.x+=sprite.dx*dt pyglet.clock.schedule_interval(update,1/60.0) pyglet.app.run()