python、GTK4、Gtk.ListStore.append和“AttributeError:'ListStore'对象没有属性'insert_with_valuesv'”

2024-10-03 13:26:18 发布

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

我是新来的编码,这可能是一个愚蠢的问题

我正在设置一个简单的Gtk.ListStore(str),但只要我附加(['whatever']),我就会得到一个“AttributeError:'ListStore'对象没有属性'insert_with_valuesv'”

我使用的是Fedora34(测试版)、python 3.9和GTK4

这是发生错误的最小示例:

#!/usr/bin/python
import gi
gi.require_version('Gtk','4.0')
from gi.repository import Gtk

simple = Gtk.ListStore(str)
simple.append(['whatever'])
Traceback (most recent call last):
  File "/home/dedum/prova/provagtk2.py", line 7, in <module>
    simple.append(['whatever'])
  File "/usr/lib/python3.9/site-packages/gi/overrides/Gtk.py", line 1009, in append
    return self._do_insert(-1, row)
  File "/usr/lib/python3.9/site-packages/gi/overrides/Gtk.py", line 1001, in _do_insert
    treeiter = self.insert_with_valuesv(position, columns, row)
AttributeError: 'ListStore' object has no attribute 'insert_with_valuesv'

我做错了什么


Tags: inpygtkusrwithlinesimplefile