import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
from gi.repository.GdkPixbuf import Pixbuf

icons = ["edit-cut", "edit-paste", "edit-copy"]

class IconViewWindow(Gtk.Window):

  def __init__(self):
    Gtk.Window.__init__(self)
    self.set_default_size(200, 200)

    liststore = Gtk.ListStore(Pixbuf, str)
    iconview = Gtk.IconView.new()
    iconview.set_model(liststore)
    iconview.set_text_column(1)

    render = Gtk.CellRendererPixbuf()
    iconview.pack_start(render, False)

    def cell_data_func(view, cell, model, iter_, *args):
        pixbuf = model.get_value(iter_, 0)
        surface = Gdk.cairo_surface_create_from_pixbuf(
            pixbuf, view.get_scale_factor(), view.get_window())
        cell.set_property("surface", surface)

    iconview.set_cell_data_func(render, cell_data_func)

    for icon in icons:
        pixbuf = Gtk.IconTheme.get_default().load_icon(icon, 64 * self.get_scale_factor(), 0)
        liststore.append([pixbuf, "Label"])

    self.add(iconview)

win = IconViewWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
