pyglet Python windowing and multimedia library with event-driven input and OpenGL rendering.
Overview pyglet is a Python library for windowing, input, graphics and media playback on desktop systems. It combines an event-driven application loop with OpenGL access and higher-level objects such as sprites and text. It can form the foundation of a custom game or visualization application, while leaving game-specific architecture to the developer.[1] [2]
Contents Events and timing A typical pyglet application creates a window and attaches handlers for drawing and input, then enters the library's application loop. That loop also services scheduled functions. Developers can customize drawing intervals and integrate more specialized behavior, but the normal workflow delegates platform event processing to pyglet. This differs from libraries whose introductory workflow has the application explicitly poll and present every frame.[2] [3]
Rendering organization Batch groups compatible vertex data and drawables so the renderer can submit related work together. Group objects associate rendering state and ordering with those objects. These abstractions are useful for sprites, labels and custom drawing, while direct OpenGL access remains available. References to editable vertex lists also matter for updating or explicitly deleting their GPU data, so scene removal and resource lifetime should be planned together.[1] [4]
Loading application content The quick-start guide distinguishes loading an application resource from loading an arbitrary user-selected image file. Resource loading locates content relative to the application rather than simply assuming the current working directory. This matters when launching a packaged program from a desktop shortcut or a different directory. Image loading provides graphics content, not conversion of another engine's scene objects or gameplay state.[2]
Licensing pyglet uses the BSD three-clause license, permitting redistribution with notice and non-endorsement conditions. Optional media components have their own terms; the media documentation specifically discusses different FFmpeg build licenses. A project's dependency choices and bundled binaries therefore remain relevant even though pyglet's own license is permissive.[5] [7]
Substitution considerations pyglet can replace parts of a pygame desktop game or multimedia workflow when the project benefits from event-driven windows and OpenGL rendering. The change involves adapting the loop, image representation, drawing and playback APIs rather than renaming imports. It is most useful as a choice of application foundation, with the actual asset formats and target systems checked separately.[2] [3] [4] [5] [8]
Also included: 4 capabilities and 0 substitute relationships. Check substitutes in section 1 and capabilities in section 3.