确定 TreeView 行的高度
我想设置树视图小部件的高度以容纳 N 行,为此我需要确定单个行的高度。
我正在使用下面的代码:
path = Gtk.TreePath().new_first()
height = tree_view.get_cell_area(path, column).height
创建树小部件、填充数据模型并选择第一行后,高度设置为 0。我缺少什么?
PS:当从“row_activated”信号处理程序运行时,相同的代码将返回有效的高度。
I want to set the height of a treeview widget to accommodate N rows, in order to do that I need to identify a single row height.
I am using the code below:
path = Gtk.TreePath().new_first()
height = tree_view.get_cell_area(path, column).height
After creating the tree widget, filling the data model, and selecting the first row, height is set to 0. What I am missing ?
P.S.: The same code will return a valid height when run from a "row_activated" signal handler.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
大概是这样的:(从gtk站点读取):
“如果path指向当前未显示的路径,则矩形的y和height属性将为0。所有单元格矩形的总和不会覆盖整个树;还有额外的例如,返回的矩形相当于传递给 gtk.CellRenderer.render() 方法的 cell_area。此方法仅在实现树视图时才有效。
您还可以使用以下代码强制在 gtk 中显示待处理的操作:
Probably this : (read from the gtk site) :
"If path points to a path not currently displayed, the y and height attributes of the rectangle will be 0. The sum of all cell rects does not cover the entire tree; there are extra pixels in between rows, for example. The returned rectangle is equivalent to the cell_area passed to the gtk.CellRenderer.render() method. This method is only valid if the treeview is realized."
You may also force the display of pending operations in gtk with this code :