Question

Here's the case: I want to append multiple gtk.VBox()'es to a gtk.ComboBox. Haven't found a way to do it yet, but searched quite a while.

Thanks in advance

EDIT: the main thing I want to reach with this is to get an image besides the text inside the ComboBox. Thank you.

Was it helpful?

Solution

You can add a CellRendererPixbuf to the ComboBox like you would in a TreeView:

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top