我正在研究Gtk3的编程,我尝试使用我安装的glade, 但是当我尝试从林间空中加载文件时,我遇到了问题:
" AttributeError: 'gi.repository.Gtk' object has no attribute 'glade' "
或者当我只使用(Gtk.Builder)时:
" AttributeError: 'Builder' object has no attribute 'glade' "
我知道我应该在python3中安装glade但我现在不用如何在下载后安装它>> __<<
谢谢你请求帮助我
#!/usr/bin/python3.3
from gi.repository import Gtk
import pygtk
gu= Gtk.Builder()
gui = gu.glade.XML("1111.glade")
"AttributeError: 'Builder' object has no attribute 'glade'
#!/usr/bin/python3.3
from gi.repository import Gtk
import pygtk
gui = Gtk.glade.XML("1111.glade")
" AttributeError: 'gi.repository.Gtk' object has no attribute 'glade' "
答案 0 :(得分:2)
GTK对象没有glade
属性。给定Gtk.Builder
对象gu
,您应该调用类似gu.add_from_file("1111.glade")
的内容。
此外,在使用GTK 3时不要导入pygtk
.PyGTK仅支持GTK 2; GTK 3由gobject-introspection的Python绑定自动处理,导入gi.repository
时会得到。