_images/pygobject.svg

PyGObject is a Python package which provides bindings for GObject based libraries such as GTK, GStreamer, WebKitGTK, GLib, GIO and many more.

It supports Linux, Windows, and macOS and works with Python 3.9+ and PyPy3. PyGObject, including this documentation, is licensed under the LGPLv2.1+.

Homepage

If you want to write a Python application for GNOME or a Python GUI application using GTK, then PyGObject is the way to go. To get started, check out the “GNOME Developer Documentation”. For more information on specific libraries, check out the GNOME Python API documentation.

import sys

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()
exit_status = app.run(sys.argv)
sys.exit(exit_status)

How does it work?

_images/overview.svg
_images/overview-dark.svg

PyGObject uses GLib, GObject, GIRepository, libffi and other libraries to access the C library (libgtk-4.so) in combination with the additional metadata from the accompanying typelib file (Gtk-4.0.typelib) and dynamically provides a Python interface based on that information.

Who Is Using PyGObject?

  • Anaconda - an installation program used by Fedora, RHEL and others

  • Apostrophe - a Markdown editor

  • Blanket - listen to different sounds

  • BleachBit - delete unnecessary files from the system

  • Bottles - run Windows software on Linux

  • Cambalache - a user interface maker for GTK

  • D-Feet - an easy to use D-Bus debugger

  • Deluge - a BitTorrent client

  • Dialect - a translation app

  • Drawing - a drawing application

  • Feeds - an RSS/Atom feed reader

  • Gajim - a fully-featured XMPP client

  • Gameeky - a learning tool for making games and learning experiences

  • Gaphor - a simple modeling tool

  • Getting Things GNOME! - a personal task organizer

  • Girens - a Plex client for playing movies, TV shows and music from your Plex library

  • GNOME Music - a music player for GNOME

  • GNOME Tweaks - a tool to customize advanced GNOME options

  • Gramps - a genealogy program

  • Komikku - a manga reader

  • Lollypop - a modern music player

  • Lutris - a video game manager

  • Meld - a visual diff and merge tool

  • Metadata Cleaner - an application to view and clean metadata in files

  • MyPaint - a nimble, distraction-free, and easy tool for digital painters

  • Nicotine+ - a graphical client for the Soulseek peer-to-peer network

  • Orca - a flexible and extensible screen reader

  • Paperwork - a personal document manager

  • Pithos - a Pandora Radio client

  • Pitivi - a free and open source video editor

  • Plots - a graph plotting app

  • Quod Libet - a music library manager / player

  • Secrets - a password manager

  • Setzer - a LaTeX editor

  • Terminator - The Robot Future of Terminals

  • Wike - a Wikipedia reader

The following applications or libraries use PyGObject for optional features, such as plugins or as optional backends:

  • beets - a music library manager and MusicBrainz tagger

  • gedit- a GNOME text editor

  • matplotlib - a python 2D plotting library

  • Totem - a video player for GNOME