案例如下: 我想将多个 gtk.VBox()'es append 到 gtk.ComboBox。 还没有找到方法,但搜索了很长一段时间。
提前致谢
编辑:我想要达到的主要目的是获取除组合框中文本之外的图像。 谢谢。
最佳答案
您可以像在 TreeView 中一样将 CellRendererPixbuf 添加到 ComboBox:
model = gtk.ListStore(gtk.gdk.Pixbuf, str)
model.append([gtk.gdk.pixbuf_new_from_file('image.png'), 'Foo'])
cb = gtk.ComboBox(model)
pb_cell = gtk.CellRendererPixbuf()
cb.pack_start(pb_cell, False)
cb.add_attribute(pb_cell, 'pixbuf', 0)
txt_cell = gtk.CellRendererText()
cb.pack_start(txt_cell, True)
cb.add_attribute(txt_cell, 'text', 1)
关于Python:gtk.ComboBox 追加框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12553425/