Overview

PyGObject 3.46, released on September 1, 2023, adds Python 3.12 support and improves the GTK binding.

Main Features

Python 3.12 support

Deprecated C APIs are updated to ensure compatibility with Python 3.12.

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

app = Gtk.Application(application_id='org.example.app')

def on_activate(app):
    win = Gtk.ApplicationWindow(application=app, title='GTK4')
    win.present()

app.connect('activate', on_activate)
app.run(None)

GTK improvements

The GTK 4 binding is improved with better signal and property handling.

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

button = Gtk.Button(label='Click')
button.connect('clicked', lambda b: print('Clicked!'))

# Improved properties
button.set_property('margin-top', 10)
button.set_property('margin-bottom', 10)

Sources