Question

I'm using OS X Mavericks with system Python 2.7.

I installed PyGObject, GTK+ and glade as I descripted below, but Python doesn't see gtk.glade module.

All libraries from Homebrew:

brew install libglade
brew install gtk+
brew install pygobject

Also, I set PYTHONPATH in .bash_profile to:

export PYTHONPATH=/usr/local/lib/python2.7/site-packages

When I run Python and try import pygtk or gtk - all works fine. But when I try to load gtk.glade I get no module error.

So I'll try install pygobject with --verbose mode and I noticed, that installer couldn't find libglade:

checking for LIBGLADE... no
…
The following modules will be built:
atk
pango
pangocairo
gtk with 2.24 API
gtk.unixprint

The following modules will NOT be built:

gtk.glade

I assumed that pygobject installer can't find path to libglade (which is installed to /usr/local/Cellar/libglade/2.6.4).

How and what path should I change? Or what else to do?

Thanks in advance!

Was it helpful?

Solution 2

PyGObject support for Gtk+2 is rater limited as Gtk+2 wasn't created with full Introspection support.

If you're using PyGobject don't use PyGtk, they are different things. In any case, why you need to use libglade? To support old Software? If that's the case, don't use PyGObject, use whatever version the Software was made with.

If you need to parse Glade files to build a GUI, use Gtk+ included GtkBuilder object, libglade was deprecated long long long long ago.

See gi.repository Windows, in particular differences with Gtk+2 and Gtk+3. Also, see How can a program that uses GUI be constructed? for how to build a Glade GUI using PyGObject, Python2.7 and GtkBuilder (this is what I suppose you need).

OTHER TIPS

I had exactly the same problem and the following DID NOT work:

brew install --verbose --glade pygtk

But the following DID work on Mavericks with Python 2.7:

brew install --verbose --with-libglade pygtk

See also this discussion

Need to include the "--glade" config option to Brew when installing, this causes the recipe/formula to make the bindings.

  1. Need to install 'glade'; this will also install 'libglade'
  2. Then install pygtk with the following option "brew install --glade pygtk"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top