Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining the height of a TreeView Row

Tags:

python

pygtk

gtk

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.

like image 903
João Pinto Avatar asked Nov 04 '22 15:11

João Pinto


1 Answers

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()
like image 136
Louis Avatar answered Nov 14 '22 23:11

Louis