Попробовал сделать вот так:
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
class TreeViewColumnExample:
# close the window and quit
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False
def __init__(self):
# Create a new window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.liststore = gtk.ListStore(str, str, str, 'gboolean')
self.treeview = gtk.TreeView(self.liststore)
self.tvcolumn = gtk.TreeViewColumn('Pixbuf and Text')
pixbuf = gtk.gdk.pixbuf_new_from_file('arch.png') # <-- my code
self.liststore.append(['Open', gtk.STOCK_OPEN, 'Open a File', True])
self.liststore.append(['New', pixbuf, 'New File', True]) # <-- my code
self.liststore.append(['Print', gtk.STOCK_PRINT, 'Print File', False])
self.treeview.append_column(self.tvcolumn)
# create a CellRenderers to render the data
self.cellpb = gtk.CellRendererPixbuf()
self.cell = gtk.CellRendererText()
# add the cells to the columns - 2 in the first
self.tvcolumn.pack_start(self.cellpb, False)
self.tvcolumn.pack_start(self.cell, True)
self.tvcolumn.set_attributes(self.cellpb, stock_id=1)
self.tvcolumn.set_attributes(self.cell, text=0)
self.treeview.set_search_column(0)
self.tvcolumn.set_sort_column_id(0)
self.treeview.set_reorderable(True)
self.window.add(self.treeview)
self.window.show_all()
def main():
gtk.main()
if __name__ == "__main__":
tvcexample = TreeViewColumnExample()
main()