I would like to to have a GTK TreeView with a background image as shown in the mockup below.
I have found methods for setting the background color of widgets, but there does not appear to be a method for setting a background pixbuf
or other image format.
I'm using Python with PyGTK but an answer in any language with GTK bindings is acceptable.
Mockup of gtkTreeView with background image:
First Attempt
Based on Jong Bor's advice, I tried the following:
style = treeview.get_style().copy()
img_pixbuf = gtk.gdk.pixbuf_new_from_file(image_filename)
img_pixmap = img_pixbuf.render_pixmap_and_mask()[0]
for state in (gtk.STATE_NORMAL, gtk.STATE_ACTIVE, gtk.STATE_PRELIGHT,
gtk.STATE_SELECTED, gtk.STATE_INSENSITIVE):
style.bg_pixmap[state] = img_pixmap
treeview.set_style(style)
At first this didn't seem to have any effect, but upon selecting an item in my TreeView
I observed the following:
Part of the background 'shows through' when a row is selected.
(Note that I'm using a background image based on my mockup, except that it has some blue color, for test purposes).
I then activated part of my GUI that clears the contents of the TreeView and redraws it, and observed this:
However as soon as I add something to the TreeView the background disappears, so I'm still not sure if this is going in the right direction.