PyGObject is a Python package providing bindings for GObject-based libraries, including GTK, GStreamer, WebKitGTK, GLib, and GIO. It allows Python applications to interact with the entire GNOME software platform through GObject Introspection. The current version is 3.56.2 and it supports Linux, Windows, macOS, and Python 3.10+.
pip install PyGObjectVerified import paths — ran on the pinned version, not inferred.
This 'Hello World' example demonstrates a basic GTK4 application using PyGObject. It initializes the GTK4 library, creates a Gtk.Application, and displays a window with 'Hello World' as its title.
Migrate code fully to modern PyGObject and GTK3+ APIs. Refer to PyGObject's 'Porting from Static Bindings' documentation.
Replace Python weakrefs with `GObject.Object.weak_ref()` for tracking GObjects.
Follow platform-specific installation instructions for system dependencies (e.g., `sudo apt install python3-gi gir1.2-gtk-4.0` on Debian/Ubuntu, MSYS2 for Windows) before `pip install PyGObject`.
To skip auto-initialization, call `gi.disable_legacy_autoinit()` before importing `Gdk` or `Gtk`.
Call GLib API directly through the `GLib` namespace (e.g., `GLib.some_function()`) after importing `GLib` from `gi.repository`.