如何创建Gtk.ListStore公司在列中表示各种类型的数据

2024-09-27 22:23:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我必须用Gtk做一个应用程序,我想用ListStore来表示列中的一些数据。但是当我尝试插入时,我得到了这个错误。你知道吗

File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 862, in _convert_row
  raise ValueError('row sequence has the incorrect number of elements')
ValueError: row sequence has the incorrect number of elements

我的数据类型是string string string(因为图像像mongodb上的string一样保存),最后一个是列表

我试着用这个表格插入:

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

我在网上读到,我可以插入一个类似GObject.TYPE_PYOBJECT的列表,但我不明白。你知道吗

对于附加数据,我执行以下操作:

def v_show(self, dic):

        for item in dic:

            name = item["name"]
            aux = ''.join(item["description"])
            description = aux
            image = item["image"]
            exercises = item["exercises"]

            data = [name, description, image, exercises]

            self.store.append(data)

Tags: 数据nameinimagegtkstringdescriptionitem

热门问题