| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
PySFML provides Python bindings for SFML.
This release line targets SFML 3.0.2.
PySFML is distributed under the terms of the zlib license.
Install the current release from PyPI:
python -m pip install --upgrade pip
python -m pip install SFMLIf you need the older bindings for SFML 2.6.2, install that release explicitly:
python -m pip install SFML==2.6.2For local development or custom SFML builds, install from a local checkout against a local SFML install:
python -m pip install --upgrade pip
export SFML_INSTALL_PREFIX=/path/to/sfml
python -m pip install .If you prefer explicit paths, set SFML_HEADERS and SFML_LIBRARIES instead of SFML_INSTALL_PREFIX.
The following PySFML program is the direct Python-style equivalent of the classic SFML C++ example that opens a window, displays a sprite and some text, and plays music:
from sfml import audio, graphics, window
render_window = graphics.RenderWindow(
window.VideoMode(800, 600),
"PySFML window",
)
texture = graphics.Texture.from_file("cute_image.jpg")
sprite = graphics.Sprite(texture)
font = graphics.Font.from_file("arial.ttf")
text = graphics.Text(font, "Hello SFML", 50)
music = audio.Music.from_file("nice_music.ogg")
music.play()
while render_window.is_open:
for event in render_window.events:
if isinstance(event, window.ClosedEvent):
render_window.close()
render_window.clear()
render_window.draw(sprite)
render_window.draw(text)
render_window.display()The main differences from the C++ form are:
The example above reflects the current Python binding surface.
On the audio side, PySFML exposes the SFML 3 listener, device, and channel-map surface, including PlaybackDevice, SoundChannel, Cone, richer SoundSource state, and Music.loop_points.
See docs/getting-started.md for source-build prerequisites and the local build flow.
The bindings are organized by SFML module:
The sfml.sf module remains available as a convenience import that re-exports the full binding surface, but the module-specific imports are the primary structure of the project.
See docs/modules.md for a module-by-module orientation. See docs/compatibility.md for Python-specific behavior differences, unsupported features, and known parity gaps.
The examples tree is curated around maintained upstream-aligned examples only.
See examples/README.md for the current examples policy and classification.
Local source-build prerequisites and test commands are documented in docs/getting-started.md.
Packaging metadata and test configuration live in pyproject.toml.
The CI and release workflows referenced below live in .github/workflows/.
The repository includes CI, release, and TestPyPI validation workflows under .github/workflows/.
For contributor-facing release and packaging details, see CONTRIBUTING.md together with the workflow definitions in .github/workflows/.
The repository source of truth is GitHub:
Jonathan De Wachter dewachter.jonathan@gmail.com
| Back | FazBrowse Home | New Git URL |