Q:

Icons not displayed while using Gtk+3 ListStore

I have made the following list store:
    # creating list view
    store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, bool)
    self.get_files(store)
    treeview = Gtk.TreeView(store)
    treeview.connect("button_press_event", self.on_button1_clicked)
    horizontal_box.pack_start(treeview, True, True, 0)

    cellrenderertext = Gtk.CellRendererText()
    cellrendererpixbuf = Gtk.CellRendererPixbuf()

    #column 0 of list view to display icons
    treeviewcolumn = Gtk.TreeViewColumn("Icon")
    treeview.append_column(treeviewcolumn)
    treeviewcolumn.pack_start(cellrendererpixbuf, True)
    treeviewcolumn.add_attribute(cellrendererpixbuf, "pixbuf", 0)

    #column 1 of list view to display names
    treeviewcolumn = Gtk.TreeViewColumn("Name")
    treeview.append_column(treeviewcolumn)
    treeviewcolumn.pack_start(cellrenderertext, True)
    treeviewcolumn.add_attribute(cellrenderertext, "text", 1)

    #column 2 of list view to display if it is directory
    treeviewcolumn = Gtk.TreeViewColumn("Is Dir?")
    treeview.append_column(treeviewcolumn)
    treeviewcolumn.pack_start(cellrenderertext, True)
    treeviewcolumn.add_attribute(cellrenderertext, "text", 2)

And I am using the following function to populate the store:
def get_files(self, store):
    for file_name in os.listdir(CURRENT_DIRECTORY):

        # modified_time = os.path.getmtime(file_name)
        if not file_name[0] == '.': 
            if os.path.isdir(os.path.join(CURRENT_DIRECTORY, file_name)):
                store.append([Gtk.Image.new_from_stock(Gtk.STOCK_DIRECTORY, Gtk.IconSize.MENU), file_name, True])
            else:
                store.append([Gtk.Image.new_from_stock(Gtk.STOCK_FILE, Gtk.IconSize.MENU), file_name, False])

The output is showing the list correctly with name and 'is directory', but it is not displaying the icons. What am I doing wrong in here?

A:

You are setting an image to a pixbuf. Instead, I would use this (condensed to show changes):
store = Gtk.ListStore(str, str, bool)

treeviewcolumn.add_attribute(cellrendererpixbuf, "icon-name", 0)

store.append('folder', file_name, True])

The docs are here.

