The topic of this article may not meet Wikipedia's general notability guideline. (April 2024) |
This article needs more citations. (April 2024) |
Pyglet is a library for the Python programming language that provides an object-oriented application programming interface for the creation of games and other multimedia applications. pyglet runs on Microsoft Windows, macOS, and Linux; it is released under the BSD Licence. pyglet was first created by Alex Holkner.
Pyglet is written entirely in Python. Images, video, and sound files in a range of formats can be done natively but can also be expanded with the libav and ffmpeg libraries. It requires no external dependencies.
Text display and formatting
pyglet.text.formats)pyglet.text.caret.Caret)pyglet.text.layout.IncrementalTextLayout)Image and sprite work
pyglet.sprite)*.gif)Graphics
pyglet.shapes)pyglet.graphics.Batch)Events and file system
pyglet.resource)pyglet.clock.Clock)pyglet.window.Window)pyglet.event.EventDispatcher)Sprites, text layouts, and text functions are implemented. Multi-level lists are supported and can be created using HTML. Different sections of the displayed document can have distinct styles. A built-in caret provides support for text editing, resembling many features of a UI text input caret.
from pyglet.window import Window
from pyglet.app import run
window = Window(caption="Hello world!", width=640, height=480)
run()
In this example, lines 1-2 import the pyglet module's necessary components. Line 4 creates a window, and line 6 calls pyglet to run its event loop. Optionally an update rate (in frames per second) can be specified in a rate parameter.