Python:gtk.ComboBox追加框

Python:gtk.ComboBox追加框,python,combobox,gtk,append,vbox,Python,Combobox,Gtk,Append,Vbox,情况是这样的: 我想将多个gtk.VBox()附加到一个gtk.ComboBox。 还没有找到一种方法,但搜索了很长时间 提前谢谢 编辑:我想达到的主要目的是在组合框中除了文本之外,还要获得一个图像。 谢谢。您可以像在树视图中一样,将CellRenderPixBuf添加到组合框中: model = gtk.ListStore(gtk.gdk.Pixbuf, str) model.append([gtk.gdk.pixbuf_new_from_file('image.png'), 'Foo'])

情况是这样的: 我想将多个gtk.VBox()附加到一个gtk.ComboBox。 还没有找到一种方法,但搜索了很长时间

提前谢谢

编辑:我想达到的主要目的是在组合框中除了文本之外,还要获得一个图像。
谢谢。

您可以像在树视图中一样,将CellRenderPixBuf添加到组合框中:

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)

您可以像在树视图中一样,将CellRenderPixBuf添加到组合框中:

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)