The included test program produces the following warning:
Warning: unable to set property ‘text’ of type ‘gchararray’ from value of type ‘PyObject’
GTK then proceeds to set property ‘text’ from value of type ‘PyObject’ perfectly. I get the warning one time no matter how many rows I append. If I clear the liststore and start over, I do not get another warning. If I make appropriate changes so that the second value is a simple string (still using the cell_data_func, though), I do not get the warning. If I create the GUI manually and leave the second value a list, I do not get the warning. Is there something in my test program that triggers the warning?
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('GLib', '2.0')
from gi.repository import Gtk, GLib
xml_data = """<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkListStore" id="liststore">
<columns>
<column type="gchararray"/>
<column type="PyObject"/>
</columns>
</object>
<template class="window" parent="GtkWindow">
<child>
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="model">liststore</property>
<property name="headers_visible">False</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn_key">
<child>
<object class="GtkCellRendererText" id="cellrenderer_key"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn_val">
<child>
<object class="GtkCellRendererText" id="cellrenderer_val"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>"""
@Gtk.Template.from_string(xml_data)
class Tester(Gtk.Window):
__gtype_name__ = 'window'
liststore = Gtk.Template.Child()
cellrenderer_val = Gtk.Template.Child()
treeviewcolumn_val = Gtk.Template.Child()
def __init__(self):
super().__init__()
self.show()
self.connect_after('destroy', self.on_destroy)
self.liststore.append(('one', ['first value']))
def func(column, cell, model, treeiter, user):
val = model.get_value(treeiter, 1) # val is a list, as it should be
val_str = val[0]
cell.set_property('text', val_str)
self.treeviewcolumn_val.set_cell_data_func(self.cellrenderer_val, func)
def on_destroy(self, obj):
loop.quit()
tester = Tester()
loop = GLib.MainLoop()
loop.run()