pyglet Documentation

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, OpenGL graphics, loading images and videos, and playing sounds and music. pyglet works on Windows, OS X 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 can optionally use AVbin to play back audio formats such as MP3, OGG/Vorbis and WMA, and video formats such as DivX, MPEG-2, H.264, WMV and Xvid.
  • 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.
  • Supports Python 2 and 3. Pick your favorite!

Please join us on the mailing list!

Programming Guide

The pyglet Programming Guide provides in-depth documentation for writing applications using pyglet. Many topics described here reference the pyglet API reference, which is listed below.

If this is your first time reading about pyglet, we suggest you start at Writing a pyglet application.

Third party libraries

Listed here are a few third party libraries that you might find useful when developing your project. Please direct any questions to the respective authors. If you would like to have your library listed here, let us know!

glooey - An object-oriented GUI library for pyglet
Every game needs a user interface that matches its look and feel. The purpose of glooey is to help you make such an interface. Towards this end, glooey provides 7 powerful placement widgets, a label widget, an image widget, 3 different button widgets, a text entry widget, a variety of scroll boxes and bars, 4 different dialog box widgets, and a variety of other miscellaneous widgets. The appearance of any widget can be trivially customized, and glooey comes with built-in fantasy, puzzle, and 8-bit themes to prove it (and to help you hit the ground running if your game fits one of those genres).
PyShaders - Pythonic OpenGL shader wrapper for python
Pyshaders aims to completely wraps the opengl2.1 shader api in a python module. Pyshaders provides a pythonic OOP api that hides the lower level (ctypes) calls. Pyshaders provides a high level api and a low level api, and it can be integrated easily with existing code because it does not occlude the underlying opengl values.

Projects using pyglet

pyglet is a fairly lightweight library, which makes it ideal to build upon. Listed here are a few projects that take advantage of pyglet “under the hood”. If you would like to have your project listed here, let us know!

cocos2d - A framework for building 2D games, demos, and other graphical/interactive applications
Cocos2d is an open source software framework. It can be used to build games, apps and other cross platform GUI based interactive programs.
Arcade - A 2D library for game development focusing on simplicity
Arcade builds on Pyglet with a focus to make creating 2D arcade games simple and easy for hobbyists and new programmers.