Skip to main content

pyGLFW

This module provides Python bindings for GLFW (on GitHub: glfw/glfw). It is a ctypes wrapper which keeps very close to the original GLFW API, except for:

  • function names use the pythonic words_with_underscores notation instead of camelCase

  • GLFW_ and glfw prefixes have been removed, as their function is replaced by the module namespace (you can use from glfw.GLFW import * if you prefer the naming convention used by the GLFW C API)

  • structs have been replaced with Python sequences and namedtuples

  • functions like glfwGetMonitors return a list instead of a pointer and an object count

  • Gamma ramps use floats between 0.0 and 1.0 instead of unsigned shorts (use glfw.NORMALIZE_GAMMA_RAMPS=False to disable this)

  • GLFW errors are reported as glfw.GLFWError warnings if no error callback is set (use glfw.ERROR_REPORTING=False to disable this, set it to ‘warn’ instead to issue warnings, set it to ‘log’ to log it using the ‘glfw’ logger or set it to a dict to define the behavior for specific error codes)

  • instead of a sequence for GLFWimage structs, PIL/pillow Image objects can be used

Installation

pyGLFW can be installed using pip:

pip install glfw

Windows

The GLFW shared library and Visual C++ runtime are included in the Python wheels.

To use a different GLFW library, you can set PYGLFW_LIBRARY to its location.

macOS

The GLFW shared library for 64-bit is included in the Python wheels for macOS.

If you are using a 32-bit Python installation or otherwise cannot use the library downloaded with the wheel, you can build and install it yourself by compiling GLFW from source (use -DBUILD_SHARED_LIBS=ON).

pyGLFW will search for the library in a list of search paths (including those in DYLD_LIBRARY_PATH). If you want to use a specific library, you can set the PYGLFW_LIBRARY environment variable to its path.

Linux

The GLFW shared library is included in the Python wheels for Linux. Although pyGLFW will try to detect whether the GLFW library for Wayland or X11 should be used, you can set the PYGLFW_LIBRARY_VARIANT variable to wayland or x11 to select either variant of the library.

If you cannot use these on your system, you can install the GLFW shared library using a package management system (e.g. apt install libglfw3 on Debian or Ubuntu) or you can build and install it yourself by compiling GLFW from source (use -DBUILD_SHARED_LIBS=ON).

pyGLFW will search for the library in a list of search paths (including those in LD_LIBRARY_PATH). If you want to use a specific library, you can set the PYGLFW_LIBRARY environment variable to its path.

cx_Freeze / PyInstaller

pyGLFW will search for the GLFW library in the current working directory, the directory of the executable and in the package on non-Windows platforms if running in an executable frozen with cx_Freeze or PyInstaller, unless the PYGLFW_LIBRARY environment variable is set.

Development Version

If you are using the development version of GLFW and would like to use wrappers for currently unreleased macros and functions, you can instead install:

pip install glfw[preview]

or set the PYGLFW_PREVIEW environment variable.

Note, however, that there will be a slight delay between the development version of GLFW and the wrappers provided by this package.

Example Code

The example from the GLFW documentation ported to pyGLFW:

import glfw

def main():
    # Initialize the library
    if not glfw.init():
        return
    # Create a windowed mode window and its OpenGL context
    window = glfw.create_window(640, 480, "Hello World", None, None)
    if not window:
        glfw.terminate()
        return

    # Make the window's context current
    glfw.make_context_current(window)

    # Loop until the user closes the window
    while not glfw.window_should_close(window):
        # Render here, e.g. using pyOpenGL

        # Swap front and back buffers
        glfw.swap_buffers(window)

        # Poll for and process events
        glfw.poll_events()

    glfw.terminate()

if __name__ == "__main__":
    main()

Metadata

Release files for glfw 2.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glfw 2.11.0
File Size Uploaded
glfw-2.11.0.tar.gz 36.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for glfw 2.11.0
File
glfw-2.11.0-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
glfw-2.11.0-py2.py3-none-win_amd64.whl Python 2, Python 3 none Windows x86-64 Details
glfw-2.11.0-py2.py3-none-win32.whl Python 2, Python 3 none Windows x86-32 Details
glfw-2.11.0-py2.py3-none-manylinux_2_28_x86_64.whl Python 2, Python 3 none Linux glibc 2.28+ x86-64 Details
glfw-2.11.0-py2.py3-none-manylinux_2_28_aarch64.whl Python 2, Python 3 none Linux glibc 2.28+ ARM64 Details
glfw-2.11.0-py2.py3-none-manylinux2014_x86_64.whl Python 3, Python 2 none Linux glibc 2.17+ x86-64 Details
glfw-2.11.0-py2.py3-none-manylinux2014_aarch64.whl Python 2, Python 3 none Linux glibc 2.17+ ARM64 Details
glfw-2.11.0-py2.py3-none-macosx_11_0_arm64.whl Python 2, Python 3 none macOS 11.0+ ARM64 Details
glfw-2.11.0-py2.py3-none-macosx_10_6_intel.whl Python 2, Python 3 none macOS 10.6+ Intel (x86-64, i386) Details

Total release size: 2.5 MB

Release files / glfw-2.11.0.tar.gz

Download URL glfw-2.11.0.tar.gz
Size 36.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4bd3a462ed02ae25455dceaeb76d154faf08b48962c0cb2cf685419a34a71305
BLAKE2b-256 checksum
How to use checksums
b289fa9cb2611314b84ffa68d76f154e1e508971d6e402b14bd2152684e35e5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / glfw-2.11.0-py3-none-win_arm64.whl

Download URL glfw-2.11.0-py3-none-win_arm64.whl
Size 174.4 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
b986dfb457d27852593686fd934c8808986ae2e4cae44ec1e8e89b1e46fc36ee
BLAKE2b-256 checksum
How to use checksums
03295c890d0da8258c64ec7a2fb76eb4c9aebe89a38abf1aecd8683b0b4c40e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / glfw-2.11.0-py2.py3-none-win_amd64.whl

Download URL glfw-2.11.0-py2.py3-none-win_amd64.whl
Size 564.5 kB
Tags Python 2 Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
bd39c1adb57b7273813e33b9768bed88d1ea656abfc914b4a6424ec0c5d62674
BLAKE2b-256 checksum
How to use checksums
78d6b0d9d83177397c018efa3579c54990f8d9b3af17fdcf97b0e549609a0571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / glfw-2.11.0-py2.py3-none-win32.whl

Download URL glfw-2.11.0-py2.py3-none-win32.whl
Size 557.7 kB
Tags Python 2 Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
9aac61d97f71088b16322a4a75cdf72ac44ea3f1c4e7e326e5dd7c427e020903
BLAKE2b-256 checksum
How to use checksums
beb2feb54341a0ad2c3a57ba462bcdef5543569a7d2a1b8751a9c46050c0e255
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / glfw-2.11.0-py2.py3-none-manylinux_2_28_x86_64.whl

Download URL glfw-2.11.0-py2.py3-none-manylinux_2_28_x86_64.whl
Size 248.5 kB
Tags Linux glibc 2.28+ x86-64 Python 2 Python 3
SHA-256 checksum
How to use checksums
76484fae4a4ef0f778a05e02422ecbe6960ae23039087fe2e0ad9742ab8c7bbe
BLAKE2b-256 checksum
How to use checksums
ccb2ee7afd7e84bc1a8a490710c3c0a7ad472b57f17909549dc7400d17f19c8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / glfw-2.11.0-py2.py3-none-manylinux_2_28_aarch64.whl

Download URL glfw-2.11.0-py2.py3-none-manylinux_2_28_aarch64.whl
Size 236.1 kB
Tags Linux glibc 2.28+ ARM64 Python 2 Python 3
SHA-256 checksum
How to use checksums
e2f6be6bb463f98b7468386ec2e5328ee5975800580c28816ec549b4c62825c4
BLAKE2b-256 checksum
How to use checksums
ca36ca10753be547d78250aed12532ec8839f19bbeb5adac11ee8153ef59ce4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / glfw-2.11.0-py2.py3-none-manylinux2014_x86_64.whl

Download URL glfw-2.11.0-py2.py3-none-manylinux2014_x86_64.whl
Size 247.0 kB
Tags Linux glibc 2.17+ x86-64 Python 2 Python 3
SHA-256 checksum
How to use checksums
a08e1135d02c9408d7622db3d391e3e33e4187754ec45633e9a482c775f4846c
BLAKE2b-256 checksum
How to use checksums
b209e3a95b97b4b174686e1b0340f9ee5b283ed65bb7cc09089fb228d36c351b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / glfw-2.11.0-py2.py3-none-manylinux2014_aarch64.whl

Download URL glfw-2.11.0-py2.py3-none-manylinux2014_aarch64.whl
Size 235.1 kB
Tags Linux glibc 2.17+ ARM64 Python 2 Python 3
SHA-256 checksum
How to use checksums
de02fcb11126242a27f5f711b31ab83ae4dfe3567caa32dc2380e1f6050c59f1
BLAKE2b-256 checksum
How to use checksums
b5ab59bfd8fb895c28f7a7c3504307d73b3eb18b85ec53a7025f9463400c4699
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / glfw-2.11.0-py2.py3-none-macosx_11_0_arm64.whl

Download URL glfw-2.11.0-py2.py3-none-macosx_11_0_arm64.whl
Size 107.2 kB
Tags Python 2 Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7405d3e3041add442e40a15ef5a880178ff90f486d576a82e112240c66f59555
BLAKE2b-256 checksum
How to use checksums
ac2cdc36e841a6a0db69c19db71a8fb4bbb211924bcf587735caea8afdd230ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / glfw-2.11.0-py2.py3-none-macosx_10_6_intel.whl

Download URL glfw-2.11.0-py2.py3-none-macosx_10_6_intel.whl
Size 110.3 kB
Tags Python 2 Python 3 macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
4f40b141657b014148893f3b8950906389f9d4d3b2bced41fbefcdcda776e9ad
BLAKE2b-256 checksum
How to use checksums
0c65c728be098d0a2fb1c81070386384640e577ec2db096e885d14ba8c3a0ffd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

2.11.0 This release

10 release files

2.10.2

9 release files

2.10.1

9 release files

2.9.0

9 release files

2.8.0

9 release files

2.7.0

9 release files

2.6.5

9 release files

2.6.4

9 release files

2.6.3

9 release files

2.6.2

9 release files

2.6.1

9 release files

2.6.0

9 release files

2.5.9

9 release files

2.5.8

9 release files

2.5.7

9 release files

2.5.6

9 release files

2.5.5

9 release files

2.5.4

9 release files

2.5.3

9 release files

2.5.2

9 release files

2.5.1

9 release files

2.5.0

9 release files

2.4.0

9 release files

2.3.0

8 release files

2.2.0

8 release files

2.1.0

7 release files

2.0.0

7 release files

1.12.0

7 release files

1.11.1

7 release files

1.11.0

7 release files

1.10.0

6 release files

1.9.1

6 release files

1.9.0

6 release files

1.8.7

4 release files

1.8.6

4 release files

1.8.5

4 release files

1.8.4

3 release files

1.8.3

3 release files

1.8.2

3 release files

1.8.1

3 release files

1.8.0

3 release files

1.7.1

3 release files

1.7.0

3 release files

1.6.0

3 release files

1.5.1

3 release files

1.5.0

1 release file

1.4.0

1 release file

1.3.3

1 release file

1.3.2

1 release file

1.3.1

1 release file

1.3.0

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page