捕获 PyGTK TreeView 重新排序
我有一个简单的 gtk.TreeView ,带有 gtk.ListStore 模型和 set_reorderable(True) ,我想捕获时发出的信号/事件用户通过拖放列表重新排序,但文档没有多大帮助:
“应用程序可以通过连接到模型的信号来监听这些更改”
所以我尝试连接模型(ListStore)信号...但令人惊讶! ListStore 没有信号,因此您被分派到 TreeModel 信号,然后我尝试与 TreeModel“行重新排序”信号连接,但没有幸运。
我应该如何捕获用户执行的列表重新排序?
I have a simple gtk.TreeView
with a gtk.ListStore
model and set_reorderable(True)
, I want to catch the signal/event emited when the user reorder through drag&drop the list, but the documentation does not help much:
"The application can listen to these changes by connecting to the model's signals"
So I tried to connect the model (ListStore) signals... but surprise! ListStore has no signals, so you are dispatched to TreeModel signals, then I tried to connect with the TreeModel "rows-reordered" signal with no lucky.
How should I catch the list reorder performed by the user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
目前 PyGTK 中还没有办法做到这一点。 “rows-reordered”是正确的信号,但除了“以某种方式重新排序”之外,在 PyGTK 中不可能从中得出任何信息。在 C GTK+ 中,您可以使用相同的信号并在回调中获取所需的信息,但在 Python 中则不然。
There is no way to do that in PyGTK currently. "rows-reordered" is the correct signal, but it is impossible to derive any information from it in PyGTK other than "somehow reordered". In C GTK+ you could use the same signal and get the required information in callback, but not in Python.
我也遇到这个问题,文档不清楚。但这是我发现的,
时,会发出“行重新排序”信号
当您有但是您仍然将信号绑定到树模型
。这将导致可见的列标题变得可单击。当您单击列标题时,它将按升序对树中的项目重新排序,如果再次单击它,则会按降序排列,如此反复。
这是一个简单的代码,您可以测试一下并了解我的意思。
I too had this problem and the docs are unclear. But here's what I found
'rows-reordered' signal is emitted when you have
However you still bind the signal to the treemodel.
That will cause the visible column header to become clickable. When you click on the column header, it will reorder the items in the tree in ascending order and then in descending order if you click it again, and back and forth.
Here's a simple code you can test and see what i mean.