PyGObject (aka PyGI)

Python Bindings for GLib/GObject/GIO/GTK+

PyGObject is a Python extension module that gives clean and consistent access to the entire GNOME software platform through the use of GObject Introspection.

PyGObject provides full support of GObject Introspection and all of its features (callbacks, GVariant support, closures, sub-classing, etc.).

Downloads

Binaries

Source

Documentation

Reference documentation can also be 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.

Another reference documentation has been written by Christoph Reiter Python GObject Introspection API Reference, it's cross-referenced with The Python GTK+ 3 Tutorial which provides a step-by-step tutorial for writing GTK programs in Python using introspection, Contribute!. The GNOME Tutorials, code samples and platform demos in Python is also a valuable documentation for those who want to get started in GNOME Programming with Python. And finally, you might also be interested in the Porting guide.

Development

Getting the code

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.

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

To build with a specific version of Python instead of the system default, add:

module_autogenargs['pygobject'] = '--with-python=/my/custom/python'

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.

Examples

Make sure you look on the files in the examples folder of pygobject.

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

Building on Win32 with cx_freeze

Make sure you have installed PyGObject with GTK3 support (look up in the download section for the binaries), install cx_freeze. Enclosed the setup.py I used in order to package a sample app (with glade support)

Maintainer Documents

Support and Feedback

Bugs and patches

Please file bug reports in the issue tracker for the 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

Projects/PyGObject/OldIndex (last edited 2019-01-12 22:34:29 by AndreKlapper)