PyGObject - GLib/GObject/GIO Python bindings

PyGObject is a Python dynamic module that enables developers to use the power of GObject, which is part of the GNOME platform.

The goal of PyGObject is to fully support GObject introspection and all its features (callbacks, GVariant support, closures, etc.).

/!\ Attention: If you want to use PyGObject to write GTK+ 3 applications the documentation is here PyGObject + GTK+-3 documentation. Contribute!



  • Current stable tarball: 3.0.x

  • Development preview tarball: 3.1.x



Reference documentation is now being generated via g-ir-doc-tool in the gobject-introspection project. This is a work in progress and as of now produces documentation which may not be that useful. Please visit the GObject Introspection Documentation project page to see how you can generate documentation directly from .gir files and read up on how to contribute to the project. Examples of the output for Gtk+ are also available to browse.

The The Python GTK+ 3 Tutorial provides a step-by-step tutorial for writing GTK programs in Python using introspection. You might also be interested in the Porting guide.


Getting the code

  • git clone git:// (browse)

Using jhbuild

For now it is suggested that PyGObject Introspection be run in a sandbox environment. The best way to do that is with jhbuild.

  • follow Jhbuild build instructions until (including) "jhbuild bootstrap"

  • Use the "gnome-apps-3.2" module set (we depend on GLib & GObject Introspection HEAD for now)

  • Add the following lines to ~/.jhbuildrc.:

moduleset = "gnome-apps-3.2"
branches["pygobject"] = "master"
modules = ['gtk+', 'pygobject']

To start building, run:

jhbuild build gtk+ pygobject

To activate jhbuild environment, run "jhbuild shell". After that, the specific console session will make use of the sandbox and you will be able to use PyGObject. Verify:

$ python
import gi
print gi.__file__

Running tests

PyGObject comes with many test cases. To run them, use

$ make check

Tests may be run in gdb or valgrind, using "check.gdb" and "check.valgrind", respectively.

Moreover, select tests may be run only:

$ make check TEST_NAMES="test_gi.TestConstant.test_constant_number test_gi.TestBoolean test_overrides"

This works with "check.gdb" and "check.valgrind" too.


Make sure you look on the files in demos and examples folders of pygobject.

Check also Philippe Normand's examples and Zach Goldberg's Zhaan Project.

Support and Feedback

Bugs and patches

Please file bug reports in Bugzilla for component "introspection". Thanks!

Patches need to be accompanied with tests, if there were none.

Contact and discussion

Porting PyGTK to PyGObject

Translations of this page

Attic/PyGObject_ru (last edited 2013-11-23 00:15:50 by WilliamJonMcCann)