为什么Python 2.7.2 pygtk解析glade GtkButtonBox时会崩溃?

1 投票
1 回答
1240 浏览
提问于 2025-04-16 21:38

以下是我遇到问题的步骤:我在glade 3.10.0中设计了一个用户界面,其中包含一个GtkButtonBox,里面有4个按钮:

<object class="GtkButtonBox" id="i_bbox">
<property name="visible">True</property>
[...] some children (buttons)

这个glade文件被加载到python脚本中:

builder_fname = "example_layout.glade"
self.root = gtk.Builder()
self.root.add_from_file(builder_fname)
self.root.connect_signals(self)

当脚本执行时,它出现了段错误,并显示了以下错误追踪信息:

./example.py:37: Warning: cannot create instance of abstract (non-instantiatable) type `GtkButtonBox'
self.root.add_from_file(builder_fname)
[1]    5088 segmentation fault (core dumped)  ./example.py

有没有人知道该怎么解决这个问题?我使用的是pygtk 2.24.0。

1 个回答

1

这个警告似乎在暗示你需要使用GtkHButtonBox或者GtkVButtonBox,而不是GtkButtonBox……这两个会出现段错误吗?

撰写回答