PyGObject

3.56.2 · active · verified Mon Apr 13

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+.

Warnings

Install

Imports

Quickstart

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.

import gi
gi.require_version('Gtk', '4.0')
from gi.repository import GLib, Gtk

class MyApplication(Gtk.Application):
    def __init__(self):
        super().__init__(application_id="com.example.MyGtkApplication")
        GLib.set_application_name('My Gtk Application')

    def do_activate(self):
        window = Gtk.ApplicationWindow(application=self, title="Hello World")
        window.present()

app = MyApplication()
app.run()

view raw JSON →