MP0
MP0

Reputation: 1033

Use glade with pygobject Gtk3

I am converting a script to use Gtk3 using the migration guide (Porting GTK2 to GTK3). I converted my import pygtk to a from gi.repository import Gtk and so on...

I'm stuck because the glade module was loaded from module gtk:

 import gtk
 import gtk.glade

but there's no way now to do that anymore.

Note that I would only need a replacement for gtk.glade.XML()...

Upvotes: 12

Views: 7492

Answers (2)

MP0
MP0

Reputation: 1033

Well, the solution is pretty obvious, after calling to Gtk.Builder() one needs to convert the old glade interface with the gtk-builder-convert command to get the interface file in the right version.

 $ gtk-builder-convert myui.glade myui.ui

And then, in the python script:

 from gi.repository import Gtk
 builder = Gtk.Builder()
 builder.add_from_file("myui.ui")

Thanks to Riccardo.

Upvotes: 14

Riccardo Galli
Riccardo Galli

Reputation: 12925

This should work

from gi.repository import Gtk
builder = Gtk.Builder()
builder.add_from_file("project.xml")

Upvotes: 4

Related Questions