Overview
Pyglet is a cross-platform windowing and multimedia library for Python, designed for developing applications involving gaming, multimedia, and visualization. Its lightweight API provides access to windowing, OpenGL graphics, images, and audio.
Key features
- Cross-platform support (Windows, macOS, Linux)
- No external dependencies or installation required
- Intuitive support for OpenGL graphics
- Image and audio loading capabilities
- Support for events and scheduled functions
Common use cases
- 2D and 3D games
- Multimedia applications
- Rich interactive applications
- Prototyping visual and audio applications
- Educational projects involving graphics and sound
Installation
pip install pyglet
Example
import pyglet
window = pyglet.window.Window()
@window.event
def on_draw():
window.clear()
pyglet.text.Label('Hello, Pyglet!',
font_name='Times New Roman',
font_size=36,
x=window.width//2, y=window.height//2,
anchor_x='center', anchor_y='center').draw()
pyglet.app.run()