Skip to main content

Python bindings for TheCherno's GLFW fork with custom titlebar support

Project description

glfw-extended

Python bindings for TheCherno's GLFW fork, which adds custom titlebar support for creating borderless windows with custom chrome (commonly used with Dear ImGui).

Installation

pip install glfw-extended

Features

This package extends the standard pyGLFW bindings with:

  • TITLEBAR window hint - Set to False to remove the titlebar while keeping window borders and shadow
  • set_titlebar_hit_test_callback() - Register a callback to handle titlebar hit testing for custom drag regions

Usage

import glfw_extended as glfw

# Initialize GLFW
if not glfw.init():
    raise RuntimeError("Failed to initialize GLFW")

# Create a window without the default titlebar
glfw.window_hint(glfw.DECORATED, glfw.TRUE)
glfw.window_hint(glfw.TITLEBAR, glfw.FALSE)

window = glfw.create_window(1280, 720, "Custom Titlebar", None, None)

# RESIZABLE must be set after window creation for TITLEBAR to take effect
glfw.set_window_attrib(window, glfw.RESIZABLE, glfw.TRUE)

# Set up hit test callback for custom drag region
def titlebar_hit_test(window, x, y, hit):
    # Example: top 30 pixels are the custom titlebar
    if y < 30:
        hit[0] = 1  # This region should act as titlebar (draggable)
    else:
        hit[0] = 0  # Normal client area

glfw.set_titlebar_hit_test_callback(window, titlebar_hit_test)

# Main loop
while not glfw.window_should_close(window):
    glfw.poll_events()
    # ... render your custom titlebar with ImGui, etc.
    glfw.swap_buffers(window)

glfw.terminate()

Note: RESIZABLE must be set to TRUE via set_window_attrib (after window creation) for TITLEBAR to have any effect.

Platform Support

Currently Windows-only (includes pre-built glfw3.dll from TheCherno's fork).

Note on Import Name

This package uses glfw_extended as the import name to avoid conflicts with the standard glfw package. If you want to use it as a drop-in replacement:

import glfw_extended as glfw

Interoperability with pyGLFW

When glfw_extended loads its custom DLL, it automatically sets the PYGLFW_LIBRARY environment variable. This means any subsequent import glfw (regular pyGLFW) will use the same custom DLL:

import glfw_extended  # Loads custom DLL, sets PYGLFW_LIBRARY
import glfw           # Uses the same custom DLL via PYGLFW_LIBRARY

# Both modules now use TheCherno's GLFW fork!
# glfw.TITLEBAR won't exist, but the underlying library supports it

This is useful if you have dependencies that import regular glfw but you want them to use the extended functionality.

Credits

  • pyGLFW by Florian Rhiem - Original Python bindings (MIT License)
  • TheCherno's GLFW fork - GLFW with titlebar support (zlib License)
  • GLFW - Original library (zlib License)

License

MIT License (same as pyGLFW). See LICENSE for details.

The bundled GLFW DLL is licensed under the zlib license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glfw_extended-0.1.0.tar.gz (561.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glfw_extended-0.1.0-py3-none-any.whl (561.5 kB view details)

Uploaded Python 3

File details

Details for the file glfw_extended-0.1.0.tar.gz.

File metadata

  • Download URL: glfw_extended-0.1.0.tar.gz
  • Upload date:
  • Size: 561.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for glfw_extended-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7fcba30ba6eda4a074c5f80eb5432ef457b8f9d12b5eb54f1e8b565e3758ebc2
MD5 104bb8385acdc004784689166e0a6464
BLAKE2b-256 bd8696660e01fe7657d559b371f180077dddda17f611979a3991eb03c1cfe8d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for glfw_extended-0.1.0.tar.gz:

Publisher: publish.yml on Azaias/glfw-extended

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file glfw_extended-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: glfw_extended-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 561.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for glfw_extended-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f26b26964cf737e97c906ec4f5657c4a39aa3063de165eff5fce643ef4ccf27
MD5 27cf22c9943ccfc6a88304024b468d7a
BLAKE2b-256 8ade537eb1056af3d2a8bff9f5e8d5a75d629906291bf9751c7d24734783ba6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for glfw_extended-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Azaias/glfw-extended

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page