pyglet Documentation
Attention
This documentation is for the pyglet 2.1 series, which has a few small API changes from the 2.0 series. Previous documentation can be found at: 2.0 maintenance. Documentation for the 1.5 series, which is the last to support legacy OpenGL, can be found here: 1.5 maintenance.
pyglet is a cross-platform windowing and multimedia library for Python, intended for developing games and other visually rich applications. It supports windowing, user interface event handling, game controllers and joysticks, OpenGL graphics, loading images and videos, and playing sounds and music. pyglet works on Windows, macOS and Linux.
Some of the features of pyglet are:
No external dependencies or installation requirements. For most application and game requirements, pyglet needs nothing else besides Python, simplifying distribution and installation.
Take advantage of multiple windows and multi-monitor desktops. pyglet allows you to use as many windows as you need, and is fully aware of multi-monitor setups for use with fullscreen games and applications.
Load images, sound, music and video in almost any format. pyglet has built-in support for common audio and image formats, and can optionally use ffmpeg to load almost any other compressed audio or video files.
pyglet is provided under the BSD open-source license, allowing you to use it for both commercial and other open-source projects with very little restriction.
Please join our Discord server, or join us on the mailing list!
If this is your first time reading about pyglet, we suggest you start at Writing a pyglet application. If you are migrating from an older version of pyglet, please read through Migrating from pyglet 2.0.
- Installation
- Writing a pyglet application
- Windowing
- Keyboard input
- Mouse input
- Controller & Joystick input
- Images and Sprites
- Displaying text
- Playing Sound and Video
- Drawing Shapes
- 3D Models and Scenes
- Application resources
- Shaders and Rendering
- Event dispatching & handling
- Simple Widgets & GUI
- Keeping track of time
- Creating an OpenGL context
- The OpenGL interface
- OpenGL ES
- Matrix and Vector Math
- The application event loop
- In-depth game example
- Runtime Options
Options
Options.audio
Options.com_mta
Options.debug_font
Options.debug_gl
Options.debug_gl_shaders
Options.debug_gl_trace
Options.debug_gl_trace_args
Options.debug_graphics_batch
Options.debug_input
Options.debug_lib
Options.debug_media
Options.debug_texture
Options.debug_win32
Options.debug_x11
Options.dpi_scaling
Options.dw_legacy_naming
Options.headless
Options.headless_device
Options.osx_alt_loop
Options.search_local_libs
Options.shader_bind_management
Options.shadow_window
Options.vsync
Options.win32_disable_shaping
Options.win32_disable_xinput
Options.win32_gdi_font
Options.xlib_fullscreen_override_redirect
Options.xsync
options
- Environment settings
- Debugging tools
- Migrating from pyglet 2.0
- pyglet
- pyglet.app
- pyglet.clock
- pyglet.display
- pyglet.customtypes
- pyglet.event
- Event types
- Attaching event handlers
- Event handler stack
- Dispatching events
EventException
EventDispatcher
EventDispatcher.dispatch_event()
EventDispatcher.event()
EventDispatcher.pop_handlers()
EventDispatcher.push_handlers()
EventDispatcher.register_event_type()
EventDispatcher.remove_handler()
EventDispatcher.remove_handlers()
EventDispatcher.set_handler()
EventDispatcher.set_handlers()
EventDispatcher.event_types
- pyglet.font
- pyglet.font.user
- pyglet.gl
GLException
Config
Config.__init__()
Config.create_context()
Config.get_gl_attributes()
Config.is_complete()
Config.match()
Config.accum_alpha_size
Config.accum_blue_size
Config.accum_green_size
Config.accum_red_size
Config.alpha_size
Config.aux_buffers
Config.blue_size
Config.buffer_size
Config.debug
Config.depth_size
Config.double_buffer
Config.forward_compatible
Config.green_size
Config.major_version
Config.minor_version
Config.opengl_api
Config.red_size
Config.sample_buffers
Config.samples
Config.stencil_size
Config.stereo
GLDEBUGPROC
GLbitfield
GLboolean
GLbyte
GLchar
GLclampd
GLclampf
GLclampx
GLdouble
GLenum
GLfloat
GLint
GLint64
GLintptr
GLshort
GLsizei
GLsizeiptr
GLsync
GLubyte
GLuint
GLuint64
GLuint64EXT
GLushort
GLException
ObjectSpace
Config
Config.__init__()
Config.create_context()
Config.get_gl_attributes()
Config.is_complete()
Config.match()
Config.accum_alpha_size
Config.accum_blue_size
Config.accum_green_size
Config.accum_red_size
Config.alpha_size
Config.aux_buffers
Config.blue_size
Config.buffer_size
Config.debug
Config.depth_size
Config.double_buffer
Config.forward_compatible
Config.green_size
Config.major_version
Config.minor_version
Config.opengl_api
Config.red_size
Config.sample_buffers
Config.samples
Config.stencil_size
Config.stereo
DisplayConfig
Context
Context.__init__()
Context.attach()
Context.create_program()
Context.delete_buffer()
Context.delete_framebuffer()
Context.delete_renderbuffer()
Context.delete_shader()
Context.delete_shader_program()
Context.delete_texture()
Context.delete_vao()
Context.destroy()
Context.detach()
Context.get_info()
Context.set_current()
Context.config
Context.context_share
Context.object_space
- pyglet.graphics
- pyglet.gui
- pyglet.image
- pyglet.info
- pyglet.input
- pyglet.math
Mat3
Mat4
Mat4.column()
Mat4.from_rotation()
Mat4.from_scale()
Mat4.from_translation()
Mat4.look_at()
Mat4.orthogonal_projection()
Mat4.perspective_projection()
Mat4.rotate()
Mat4.row()
Mat4.scale()
Mat4.translate()
Mat4.transpose()
Mat4.a
Mat4.b
Mat4.c
Mat4.d
Mat4.e
Mat4.f
Mat4.g
Mat4.h
Mat4.i
Mat4.j
Mat4.k
Mat4.l
Mat4.m
Mat4.n
Mat4.o
Mat4.p
Quaternion
Vec2
Vec3
Vec4
clamp()
- pyglet.media
- pyglet.resource
- pyglet.sprite
- Drawing multiple sprites
Sprite
Sprite.group_class
Sprite.__init__()
Sprite.delete()
Sprite.draw()
Sprite.get_sprite_group()
Sprite.on_animation_end()
Sprite.update()
Sprite.batch
Sprite.blend_mode
Sprite.color
Sprite.event_types
Sprite.frame_index
Sprite.group
Sprite.height
Sprite.image
Sprite.opacity
Sprite.paused
Sprite.position
Sprite.program
Sprite.rotation
Sprite.scale
Sprite.scale_x
Sprite.scale_y
Sprite.visible
Sprite.width
Sprite.x
Sprite.y
Sprite.z
SpriteGroup
- pyglet.shapes
- pyglet.text
- pyglet.text.caret
- pyglet.text.document
- pyglet.text.layout
- Style attributes
IncrementalTextDecorationGroup
IncrementalTextLayout
IncrementalTextLayoutGroup
ScrollableTextDecorationGroup
ScrollableTextLayout
ScrollableTextLayoutGroup
TextDecorationGroup
TextLayout
TextLayoutGroup
get_default_decoration_shader()
get_default_image_layout_shader()
get_default_layout_shader()
Weight
DocumentDecodeException
DocumentDecoder
DocumentLabel
HTMLLabel
Label
decode_attributed()
decode_html()
decode_text()
get_decoder()
load()
- pyglet.window
- Contributing
- Development environment
- Documentation and Type Hints
- Testing pyglet
- Making a pyglet release
- OpenGL Interface Implementation
- ctypes Wrapper Generation
- wraptypes
- Media manual
- Media logging manual