与pygobject Gtk3一起使用林间空地 [英] Use glade with pygobject Gtk3
问题描述
我正在使用迁移指南(将GTK2移植到GTK3 )将脚本转换为使用Gtk3.我将import pygtk
转换为from gi.repository import Gtk
,依此类推...
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...
我被卡住是因为林间空地模块是从模块gtk加载的:
I'm stuck because the glade module was loaded from module gtk:
import gtk
import gtk.glade
但是现在没有办法了.
请注意,我只需要替换gtk.glade.XML()
...
Note that I would only need a replacement for gtk.glade.XML()
...
推荐答案
嗯,解决方案非常明显,在调用Gtk.Builder()
之后,需要使用gtk-builder-convert
命令转换旧的glade接口以获取接口文件.在正确的版本中.
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
然后,在python脚本中:
And then, in the python script:
from gi.repository import Gtk
builder = Gtk.Builder()
builder.add_from_file("myui.ui")
感谢里卡多.
这篇关于与pygobject Gtk3一起使用林间空地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!