#!/usr/bin/env python

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


window = Gtk.Window()
window.set_default_size(400, 300)
window.connect("destroy", Gtk.main_quit)

scroll = Gtk.ScrolledWindow()
window.add(scroll)

store = Gtk.ListStore(str, str, str)

view = Gtk.TreeView(model=store)
scroll.add(view)

# add some columns
for c in range(0, store.get_n_columns()):
    def on_cell_edited(widget, path, text, data=None):
        store[path][data] = text

    renderer = Gtk.CellRendererText()
    renderer.set_property("editable", True)
    renderer.connect("edited", on_cell_edited, c)
    column = Gtk.TreeViewColumn("Column %d" % (c + 1), renderer, text=c)
    view.append_column(column)

# add some data
for r in range(0, 3):
    store.append(["%d,%d" % (c + 1, r + 1)
                  for c in range(0, store.get_n_columns())])

window.show_all()
Gtk.main()
