pyglet Documentation
Note
This is the documentation for pyglet version 3.0. If you need a different one use the docs version selector.
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 the conversation on our Discord server.!
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 to pyglet 3.x.
Programming Guide
- 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
OptionsOptions.audioOptions.backendOptions.com_mtaOptions.debug_apiOptions.debug_api_shadersOptions.debug_api_traceOptions.debug_api_trace_argsOptions.debug_comOptions.debug_fontOptions.debug_graphics_batchOptions.debug_inputOptions.debug_libOptions.debug_mediaOptions.debug_waylandOptions.debug_win32Options.debug_x11Options.dpi_scalingOptions.dw_legacy_namingOptions.headlessOptions.headless_deviceOptions.optimize_statesOptions.osx_alt_loopOptions.pyodideOptions.search_local_libsOptions.shader_bind_managementOptions.text_antialiasingOptions.text_shapingOptions.vsyncOptions.waylandOptions.win32_disable_xinputOptions.win32_gdi_fontOptions.xlib_fullscreen_override_redirectOptions.xsync
options- Environment settings
- Debugging tools
- Migrating to pyglet 3.x
- Pyodide Integration
API Reference
- pyglet
- pyglet.app
- pyglet.clock
- pyglet.display
- pyglet.customtypes
- pyglet.enums
AddressModeBlendFactorBlendFactor.CONSTANT_ALPHABlendFactor.CONSTANT_COLORBlendFactor.DST_ALPHABlendFactor.DST_COLORBlendFactor.ONEBlendFactor.ONE_MINUS_CONSTANT_ALPHABlendFactor.ONE_MINUS_CONSTANT_COLORBlendFactor.ONE_MINUS_DST_ALPHABlendFactor.ONE_MINUS_DST_COLORBlendFactor.ONE_MINUS_SRC_ALPHABlendFactor.ONE_MINUS_SRC_COLORBlendFactor.SRC_ALPHABlendFactor.SRC_COLORBlendFactor.ZERO
BlendOpCompareOpComponentFormatFramebufferAttachmentFramebufferAttachment.COLOR0FramebufferAttachment.COLOR1FramebufferAttachment.COLOR10FramebufferAttachment.COLOR11FramebufferAttachment.COLOR12FramebufferAttachment.COLOR13FramebufferAttachment.COLOR14FramebufferAttachment.COLOR15FramebufferAttachment.COLOR2FramebufferAttachment.COLOR3FramebufferAttachment.COLOR4FramebufferAttachment.COLOR5FramebufferAttachment.COLOR6FramebufferAttachment.COLOR7FramebufferAttachment.COLOR8FramebufferAttachment.COLOR9FramebufferAttachment.DEPTHFramebufferAttachment.DEPTH_STENCILFramebufferAttachment.STENCIL
FramebufferTargetGraphicsAPIStretchStyleTextureFilterTextureTypeTextureWrappingWeight
- pyglet.event
- Event types
- Attaching event handlers
- Event handler stack
- Dispatching events
EventExceptionEventDispatcherEventDispatcher.register_event_type()EventDispatcher.dispatch_event()EventDispatcher.event()EventDispatcher.pop_handlers()EventDispatcher.post_event()EventDispatcher.push_handlers()EventDispatcher.remove_handler()EventDispatcher.remove_handlers()EventDispatcher.set_handler()EventDispatcher.set_handlers()EventDispatcher.event_types
- pyglet.font
- pyglet.graphics
- pyglet.graphics.allocation
- pyglet.graphics.framebuffer
- pyglet.graphics.shader
- pyglet.graphics.vertexbuffer
- pyglet.graphics.vertexdomain
BaseStreamIndexStreamIndexedVertexDomainBaseIndexedVertexGroupBucketIndexedVertexListBaseInstanceIndexedVertexListBaseInstanceStreamInstanceVertexListBaseInstancedIndexedVertexDomainBaseInstancedVertexDomainBaseVertexArrayBindingVertexArrayProtocolVertexDomainBaseVertexGroupBucketVertexListBaseVertexStream
- pyglet.gui
- pyglet.image
- pyglet.info
- pyglet.input
- pyglet.math
Mat3Mat4Mat4.from_rotation()Mat4.from_scale()Mat4.from_translation()Mat4.look_at()Mat4.orthogonal_projection()Mat4.perspective_projection()Mat4.column()Mat4.rotate()Mat4.row()Mat4.scale()Mat4.translate()Mat4.transpose()Mat4.aMat4.bMat4.cMat4.dMat4.eMat4.fMat4.gMat4.hMat4.iMat4.jMat4.kMat4.lMat4.mMat4.nMat4.oMat4.p
QuaternionVec2Vec3Vec4clamp()
- pyglet.media
- pyglet.resource
- pyglet.sprite
- Drawing multiple sprites
SpriteSprite.group_classSprite.__init__()Sprite.delete()Sprite.draw()Sprite.get_sprite_group()Sprite.on_animation_end()Sprite.update()Sprite.batchSprite.blend_modeSprite.colorSprite.event_typesSprite.frame_indexSprite.groupSprite.heightSprite.imageSprite.opacitySprite.pausedSprite.positionSprite.programSprite.rotationSprite.scaleSprite.scale_xSprite.scale_ySprite.visibleSprite.widthSprite.xSprite.ySprite.z
SpriteGroup
- pyglet.shapes
- pyglet.text
- pyglet.text.caret
- pyglet.text.document
- pyglet.text.layout
- Style attributes
IncrementalTextDecorationGroupIncrementalTextLayoutIncrementalTextLayoutGroupScrollableTextDecorationGroupScrollableTextLayoutScrollableTextLayoutGroupTextDecorationGroupTextLayoutTextLayoutGroupget_default_decoration_shader()get_default_image_layout_shader()get_default_layout_shader()
DocumentDecodeExceptionDocumentDecoderDocumentLabelHTMLLabelLabeldecode_attributed()decode_html()decode_text()get_decoder()load()
- pyglet.window
External Resources
Development Guide
- 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