Simple example of a gtk Image in a 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.
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()
win = gtk.Window()
if __name__ == '__main__':
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.