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

  • git clone git://git.gnome.org/pygobject (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 "gnome-apps-<gnome-version>" as the module set. Where <gnome-version> is the version of the gnome environment being targeted: see the RoadMap and the current Modulesets pages.

  • For example, adding the following to ~/.jhbuildrc will setup a development environment for gnome 3.12 and pull in the latest development source for pygobject and gobject-introspection:

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 demos and examples folders 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 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

  • PyGObject_ru - Перевод на Русский язык.

Projects/PyGObject (last edited 2016-02-23 10:25:26 by AndreKlapper)