I am not sure but I think it is possible to use more then one Gtk.CellRenderer
in a Gtk.TreeViewColumn
when using pack_start()
.
But I can't get it run and don't see what is wrong. The TreeView in this example code is empty.
#!/usr/bin/env python3
import random
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
class TreeView(Gtk.TreeView):
def __init__(self):
# model
self.model = Gtk.ListStore.new([int, int])
for i in range(5):
self.model.append([i, (i*10)])
# view
Gtk.TreeView.__init__(self, self.model)
col = Gtk.TreeViewColumn.new()
col.set_title('two model fields')
self.rendererA = Gtk.CellRendererText()
col.add_attribute(self.rendererA, 'text', 0)
col.pack_end(self.rendererA, True)
self.rendererB = Gtk.CellRendererText()
col.add_attribute(self.rendererB, 'text', 1)
col.pack_end(self.rendererB, True)
self.append_column(col)
if __name__ == '__main__':
win = Gtk.Window.new(0)
win.view = TreeView()
win.add(win.view)
win.connect('destroy', Gtk.main_quit)
win.show_all()
Gtk.main()
And the Gtk-Warning is
(_col.py:22411): Gtk-CRITICAL **: 13:23:09.919: gtk_cell_area_attribute_connect: assertion 'gtk_cell_area_has_renderer (area, renderer)' failed
You did everything right except function order. Pack first, add_attribute second.