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.
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 :
## force the refresh of the screen
while gtk.events_pending():
gtk.main_iteration()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With