Hi, Le 14/02/2015 01:18, Roland Koebler a écrit : > I would like to render either an icon or a pixbuf at the same place in > a TreeView. So, I tried to use a CellRendererPixbuf and either set the > pixbuf- or icon-name-property: > > - Use a liststore with two columns, one for the pixbuf, one for the > icon-name. > - Set only one of pixbuf or icon-name, and the other to None. > > But in my tests, the pixbuf is always ignored, and either the icon-name- > image is shown or nothing. > […] > > Am I doing anything wrong? > Or is the documentation wrong? > Or do I have to only use pixmaps, and therefore create a pixmap from > every icon-name I want to use?
I don't know if there is a simpler way to do what you want but I would imagine that every time one of the properties is set it takes precedence. Anyway, you could use gtk_tree_view_column_set_cell_data_func() to manually set the appropriate property. I'm not very used to do this in Python, so it might not be the cleanest possible (like I don't know if set_property() is the wait to go), but it works: ... col = Gtk.TreeViewColumn("Image", renderer) def cell_data(col, cell, model, iter, data=None): name, pix = model.get(iter, 0, 1) if pix is not None: cell.set_property('pixbuf', pix) else: cell.set_property('icon-name', name) col.set_cell_data_func(renderer, cell_data) ... Regards, Colomban _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list