0

I recently made my first app with pygtk using Anjuta. It works well under Linux, so it's time to share it with relatives and friends. I installed Python, pygtk and the Gtk all-in-one bundle (Cairo, pyGobject ect) on windows and tried to run it.

I had an error saying self.builder.add_from_file(UI_FILE)

Digging a bit in the code I found out that my UI_FILE contains

<!-- interface-requires gtk+ 3.0 -->

And my python console says:

>>> import gtk
>>> gtk.gtk_version
(2, 22, 1)

As far as I know I installed the latest version of Gtk on my win32 machine. Now I don't know how to tackle the problem: re-designing the interface to be compatible with gtk2.22.1? (then how?) using a cross compiler from my linux distro? (at what cost in complexity/stability?)

Thank you for your time, and you answers.

monsieur_h
  • 1,360
  • 1
  • 10
  • 20
  • related: [gi.repository Windows](http://stackoverflow.com/a/12986596/4279) – jfs Oct 20 '12 at 09:58
  • That's absolutely related, it confirms the problem comes from win32 - Gtk3 compatibility. But I still don't know how to make it work. – monsieur_h Oct 20 '12 at 10:34

2 Answers2

0

Remove all the widgets from your interface that are not compatible with GTK 2 (such as Grid, Overlay, etc.) If you have a Glade version from the 3.8 series I think you can automatically check which widgets are appropriate by going to the project properties and selecting GTK 2.24 as the target version. Then there is a button called "Verify widget versions and deprecations" that you can click to make sure that all the widgets you are using work with that version.

By the way, 2.22.1 is definitely not the latest version for Windows. It's 2.24.7 or .8.

ptomato
  • 56,175
  • 13
  • 112
  • 165
0

The up-to-date answer to this is that you can use Gtk3 on windows, using the recent PyGobject packages that are downloadable here.

Then instead of using the following (which loads pygtk):

import gtk

You should use

from gi.repository import Gtk

If your code used to rely on pygtk, you have the following choices (see the porting guide)

  • use the module pygtkcompat (which allows you to keep supporting Gtk 2.x)
  • port to the introspection approach, which can be mostly automated through a script available in said porting guide, pygi-convert.sh (which just consist of a lot of regular expression replacements)
Cimbali
  • 11,012
  • 1
  • 39
  • 68