I'm trying to display properties of an object on different columns of a Gtk.TreeView
. Say I have the following:
class MyClass(GObject.GObject):
def __init__(self, first, last, age):
self.first = first
self.last = last
self.age = age
And I want to store instances in a Gtk.ListStore
as shown below.
store = Gtk.ListStore(MyClass)
Now, when creating the Gtk.TreeView
, I don't know how to specify that 2 columns must be rendered, one for the first
property and the other for the age
property.
view = Gtk.TreeView(model=store)
# Columns for first and age added here
...
These posts (1) and (2) somewhat explain how to use custom types, but only use 1 column (then the length of the number of columns in the store
matches the number of columns in the view
). I sounds like what I'm trying to do would be a common thing without needing any workarounds. Perhaps it's about sub-classing Gtk.ListStore
to have it tell the view
that it has several columns and how to fetch each value?
Also, how do I make so that changes to MyClass instances in the store
are automatically notified and reflected on the view
?