pyglet: Multimedia Library for Python


pyglet is a cross-platform windowing and multimedia library for Python. pyglet main features 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.
  • 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 provides also an OpenGL support via the package but from the doc, is less pythonic than PyOpenGL.

I’ll test this cool Python lib with GeeXLab as soon as possible (I will update GeeXLab shortly).

Here a short code snippet:

from pyglet import image
from import *

img = image.load('image.jpg')
width, height = img.width, img.height

GL_texture = img.get_texture()
glEnable( # typically target is GL_TEXTURE_2D

rawimage = image.get_image_data()
format = 'RGBA'
pitch = rawimage.width * len(format)
pixels = rawimage.get_data(format, pitch)


  • malcolm

    I was wondering if pyglet would allow Geexlab to display streaming video as texture.
    The infrastructure seems to be in pyglet but what about the performance ?

  • From what I saw in the doc, I think it should be possible. Wait and see 😉