2

I have a gtk.TreeViewColumn that contains 14 gtk.CellRendererPixbuf attributes. Most of them are empty most of the time (the assiciated TreeStore value is None).

These icons always appear spaced as though they were all present, however I would like empty cell renderers to collapse, stacking the icons which are there on the left.

This is how it currently appears:

enter image description here

The missing icons are associated with None.

I have looked through the TreeViewColumn and CellRenderer documentation but I am stumped.

jsj
  • 9,019
  • 17
  • 58
  • 103
  • So If I understand you correctly, you don't want columns in your TreeView to persist if there are holes in a row? I'm doubtful that it's going to work. (Have you concidered just placing the icons in `HBox`:s and the `HBox`:s in a `VBox`? – deinonychusaur Nov 04 '12 at 11:50
  • Also, it might be slightly more likely to get it too work as you wish with GTK3 in combination with some CSS magic (still won't believe it until I see it though). – deinonychusaur Nov 04 '12 at 11:53
  • @deinonychusaur all the icons are in the same column. One column, 14 pixbuf renderers - i'll post a pic of what I mean – jsj Nov 05 '12 at 13:23
  • I think this is exactly your question, that is -- make your own CellRenderer (the accepted answer, haven't tried it myself and some links are broken): http://stackoverflow.com/questions/3596926/pygtk-is-this-possible-to-draw-treeview-listed-like-iconview – deinonychusaur Nov 05 '12 at 15:17

1 Answers1

3

The solution is to write your own CellRenderer which accepts lists of icons. Look at the implementation of such a renderer of Getting Things GNOME! ToDO app:

http://bazaar.launchpad.net/~gtg/gtg/trunk/view/head:/GTG/gtk/browser/CellRendererTags.py

Then you set tag_list attribute with a list of objects to display. (In the app you can show a solid color or an icon)

The result looks like this (list of icons is the first column):

enter image description here

izidor
  • 4,068
  • 5
  • 33
  • 43