Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import os.path
import sys
from gi.repository import Gtk, GdkPixbuf
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
path = sys.argv[1]
def cell_data_func(column, cell, model, iter, data):
path, pb = model.get(iter, 0, 1)
if pb is None:
print("Loading %s" % path)
pb = GdkPixbuf.Pixbuf.new_from_file_at_size(path, 60, 60)
model.set(iter, 1, pb)
cell.set_property('pixbuf', pb)
store = Gtk.ListStore(str, GdkPixbuf.Pixbuf)
renderer_txt = Gtk.CellRendererText()
renderer_pb = Gtk.CellRendererPixbuf()
view = Gtk.TreeView()
view.set_model(store)
column_pb = Gtk.TreeViewColumn("Image")
column_pb.pack_start(renderer_pb, True)
column_pb.set_cell_data_func(renderer_pb, cell_data_func)
view.append_column(column_pb)
column_txt = Gtk.TreeViewColumn("Path", renderer_txt, text=0)
view.append_column(column_txt)
viewport = Gtk.ScrolledWindow()
viewport.add(view)
window = Gtk.Window()
window.add(viewport)
window.show_all()
for f in os.listdir(path):
f = os.path.join(path, f)
store.append((f, None))
Gtk.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment