pygtk:无效的树视图迭代器
我的树视图设置有点复杂。这就是视图的设置方式:
self.hsModel = gtk.TreeStore(*[c[0] for c in columns])
self.hsModelFilter = self.hsModel.filter_new()
self.hsModelSort = gtk.TreeModelSort(self.hsModelFilter)
self.hsSelect = gtk.TreeView(self.hsModelSort)
也就是说,我有一个模型,然后对其进行过滤,然后对其进行排序,然后视图显示排序后的模型。在函数中,我将一些内容附加到基本模型中:
iter = self.hsModel.append(None, row)
然后我尝试从树视图中选择刚刚添加的内容 (hsSelect
):
fiter = self.hsModelFilter.convert_child_iter_to_iter(iter)
siter = self.hsModelSort.convert_child_iter_to_iter(None, fiter)
self.hsSelect.get_selection().select_iter(siter)
但是,这有时会出现错误。我现在无法重现它,但它说 iter 的标记与树模型的标记不匹配。知道我做错了什么吗?
I have a somewhat complicated set-up for a treeview. This is how the view is set up:
self.hsModel = gtk.TreeStore(*[c[0] for c in columns])
self.hsModelFilter = self.hsModel.filter_new()
self.hsModelSort = gtk.TreeModelSort(self.hsModelFilter)
self.hsSelect = gtk.TreeView(self.hsModelSort)
That is, I have a model, then I filter it, then I sort it, then the view displays the sorted model. In a function, I append something to the base model:
iter = self.hsModel.append(None, row)
Then I attempt to select what I just added from the tree view (hsSelect
):
fiter = self.hsModelFilter.convert_child_iter_to_iter(iter)
siter = self.hsModelSort.convert_child_iter_to_iter(None, fiter)
self.hsSelect.get_selection().select_iter(siter)
However, this sometimes gives an error. I can't reproduce it now, but it says the iter's stamp doesn't match the tree model's stamp. Any idea what I'm doing incorrectly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论