Simple example of a gtk Image in a TreeView
TreeView

Here is a super simple example of a pixbuf in a treeview.

The pixbuf is loaded from a file, then set in a treeviewcolumn with a cellrenderer. The column is appended to the treeview. It’s all contained in the init of one class to make it short and simple.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#!/usr/bin/python import gtk class ImgTree(): def __init__(self, f): store = gtk.ListStore(gtk.gdk.Pixbuf) store.append([ gtk.gdk.pixbuf_new_from_file(f) ]) cell = gtk.CellRendererPixbuf() tvcol = gtk.TreeViewColumn('Heading', cell, pixbuf=0) tv = gtk.TreeView() tv.set_model(store) tv.append_column(tvcol) win = gtk.Window() win.set_position(gtk.WIN_POS_CENTER) win.add(tv) win.show_all() if __name__ == '__main__': ImgTree('/usr/share/icons/coffee.png') gtk.main() |
Style
There are many ways to write this class. This is only one of those ways. There are several style guides out there, but none of them are (or should be considered) strict rule sets you must code by.
You should play around and experiment with different attributes and layouts before deciding which method is the best for you.