python – GenericTreeModel与PyGObject Introspection Gtk 3?
作者:互联网
我正在尝试在Python3中编写基于GenericTreeModel的我自己的Gtk 3-TreeModel,但是这个错误:
AttributeError: ‘gi.repository.Gtk’ object has no attribute ‘GenericTreeModel’
是否已重命名GenericTreeModel?
提前致谢.
解决方法:
我在PyGObject和Gtk中都找不到对GenericTreeModel的引用,但我认为你要找的只是TreeModel:
http://developer.gnome.org/gtk3/stable/GtkTreeModel.html
TreeModel是接口,由ListStore,TreeModelFilter,TreeModelSort和TreeStore实现.
>>> from gi.repository import Gtk
>>> dir(Gtk.TreeModel)
['__bool__', '__class__', '__delattr__', '__delitem__', '__dict__', '__doc__',
'__format__', '__gdoc__', '__getattribute__', '__getitem__', '__gtype__', '__hash__',
'__info__', '__init__', '__iter__', '__len__', '__module__', '__new__', '__nonzero__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__',
'__str__', '__subclasshook__', '__weakref__', '_convert_row', '_convert_value',
'_getiter', 'filter_new', 'foreach', 'get', 'get_column_type', 'get_flags', 'get_iter',
'get_iter_first', 'get_iter_from_string', 'get_n_columns', 'get_path',
'get_string_from_iter', 'get_value', 'iter_children', 'iter_has_child',
'iter_n_children', 'iter_next', 'iter_nth_child', 'iter_parent', 'iter_previous',
'ref_node', 'row_changed', 'row_deleted', 'row_has_child_toggled', 'row_inserted',
'set_row', 'sort_new_with_model', 'unref_node']
编辑:
在旧的PyGtk API中找到了what you are looking for,遗憾的是,这是一个仅限PyGtk的创建.有了内省的东西,你只能得到Gtk直接提供的东西,所以你必须直接处理TreeModel.
希望能帮助到你.
标签:python,python-3-x,gtk3,pygobject,treemodel 来源: https://codeday.me/bug/20190725/1538516.html