检测gtk.treeview中的列是否调整大小 [英] Detect when column in gtk.treeview is resized

查看:379
本文介绍了检测gtk.treeview中的列是否调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以捕获什么信号来检测列在 gtk.TreeView 中更改大小的时间?我似乎无法在文档中找到它。

解决方案

gtk.TreeViewColumn 不是窗口小部件,所以他们很遗憾没有专门的尺寸变更信号。但是您可以注册一个回调函数,该函数接收宽度更改通知

  def onColWidthChange(col,width):
#请注意,width是一个GParamInt对象,不是整数
...

col.connect(notify :: width,onColWidthChange)
$ b $ p

在这个例子中, col 必须是 gtk.TreeViewColumn 对象。如果你没有在代码中初始化列,你可以使用 gtk.TreeView.get_column 获取这些对象。



如果你只有当treeview改变它的大小时才需要通知,你可以使用它的size-allocate信号。


What signal can I catch to detect when a column changes size in a gtk.TreeView? I can't seem to find it in the docs.

解决方案

gtk.TreeViewColumns aren't widgets so they unfortunately don't have a dedicated signal for size changes. But you can register a callback function that receives "width" change notifications:

def onColWidthChange(col, width):
    # Note that "width" is a GParamInt object, not an integer
    ...

col.connect("notify::width", onColWidthChange)

In the example, col must be a gtk.TreeViewColumn object. If you don't initialize the columns in code, you can use gtk.TreeView.get_column to get these objects.

If you only need notifications when the treeview changes its size, you can use its "size-allocate" signal instead.

这篇关于检测gtk.treeview中的列是否调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆