Application-wide functionality.
Most applications need only call run after creating one or more windows to begin processing events. For example, a simple application consisting of one window is:
import pyglet
win = pyglet.window.Window()
pyglet.app.run()
To handle events on the main event loop, instantiate it manually. The following example exits the application as soon as any window is closed (the default policy is to wait until all windows are closed):
event_loop = pyglet.app.EventLoop()
@event_loop.event
def on_window_close(window):
event_loop.exit()
since: | pyglet 1.1 |
---|