Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gi.repository Windows

I'm developing an app which has to be 100% compatible on windows and on linux. On linux I have no problems, but on windows I came up with this message: from gi.repository import Gtk ImportError: No module named gi

I installed pygobject, pygtkallinone, gtk.. what am I missing?

like image 258
Yerko Antonio Avatar asked Oct 19 '12 19:10

Yerko Antonio


People also ask

What is GI repository?

gi. repository is the Python module for PyGObject (which stands for Python GObject introspection) which holds Python bindings and support for the GTK+ 3 toolkit and for the GNOME apps. See Projects/PyGObject on the GNOME Wiki.


2 Answers

Most of Havok answer is correct, except that documentation has been improved a lot lately, with a Tutorial:

  • http://python-gtk-3-tutorial.readthedocs.org/en/latest/

Including a PDF version for offline reading:

  • http://media.readthedocs.org/pdf/python-gtk-3-tutorial/latest/python-gtk-3-tutorial.pdf

And a complete API reference manual, not only of Gtk but also many other libraries that you can use with introspection:

  • http://lazka.github.io/pgi-docs/

on windows the support is great, a lot of effort has been put in creating all the windows executables and libraries, the last release of pygi-aio is 3.10.6:

  • http://sourceforge.net/projects/pygobjectwin32/files/?source=navbar

I've also put instructions on the Gnome wiki on how to build on win32 with pygobject introspection, it's not that hard, I've also uploaded a setup.py that actually works:

  • https://wiki.gnome.org/action/show/Projects/PyGObject?action=show&redirect=PyGObject#Building_on_Win32_with_cx_freeze

So the answer is, don't go with PyGTK

like image 72
gianmt Avatar answered Sep 21 '22 12:09

gianmt


gi.repository module is called PyGObject and is for Gtk+3 and is not yet available for Windows (there has been experiments, but is not ready AFAIK). https://live.gnome.org/PyGObject

gtk module is called PyGtk and is for Gtk+2 and is very mature on Windows platforms (in particular 2.24). http://www.pygtk.org/

What's the difference?

  • PyGObject has some scarse Windows support. PyGtk has great support for this OS.
  • PyGObject is what is called a dynamic binding and PyGtk is a static one.
  • PyGObject is new and the future and PyGtk is the past, mature and some day will be deprecated.
  • PyGObject documentation and examples are very very limited, and PyGtk one are very very complete: http://developer.gnome.org/pygtk/stable/
  • They are not compatible, you can't use both and you need to choose one.
  • PyGObject is in active development, no new features will be introduced for PyGtk.
  • If you use Glade, the lastest version will be for PyGObject (for example 3.12.1). If you want to use Glade for PyGtk install the 3.8.0 version.

If you choose to go PyGtk there is great support for freezing the application. You can check my documentation and support files for my application here: http://sourceforge.net/p/nestededitor/code/247/tree/trunk/dist/windows/

Hope it helps.

EDIT:

Many things have changed in two years. Please see gianmt answer.

like image 34
Havok Avatar answered Sep 21 '22 12:09

Havok