
from gi.repository import Gtk


class TreeViewTest(Gtk.Window):

	def __init__(self):
		super(Gtk.Window, self).__init__()

		scrolled_window = Gtk.ScrolledWindow()
		scrolled_window.set_size_request(400, 300)
		self.add(scrolled_window)

		self.tree_view = Gtk.TreeView()
		scrolled_window.add(self.tree_view)

		self.model = Gtk.ListStore(str)
		self.model.append(("Eins", ))
		self.model.append(("Zwei", ))
		self.tree_view.set_model(self.model)

		cell = Gtk.CellRendererText()
		column = Gtk.TreeViewColumn("Titel", cell)
		self.tree_view.append_column(column)
		column.set_cell_data_func(cell, self.test_cell_data_func)

		self.connect("destroy", Gtk.main_quit)

		self.show_all()

	def test_cell_data_func(self, column, cell_renderer, tree_model, iter, data=None):
		cell_renderer.set_property('text', tree_model.get_value(iter, 0))


if __name__ == "__main__":
	window = TreeViewTest()
	Gtk.main()

