[pygtk] Row number column

Fredrik Corneliusson fredrik.corneliusson at gmail.com
Wed May 9 19:22:31 WST 2007


Thanks Osmo, worked like a charm!

/Fredrik

On 5/9/07, Osmo Salomaa <otsaloma at cc.hut.fi> wrote:
> ti, 2007-05-08 kello 10:59 +0200, Fredrik Corneliusson kirjoitti:
> > I wonder about the best way to add row numbers to a gtk.TreeView with
> > a gtk.ListStore model.
>
> I believe the best way is to add an integer column to the list store and
> use 'set_cell_data_func' as follows to set the row number to update
> automatically after whatever changes in the list store.
>
> def set_row_number(column, renderer, store, itr):
>     renderer.props.text = store.get_path(itr)[0] + 1
> column.set_cell_data_func(renderer, set_row_number)
>
> --
> Osmo Salomaa
>
>


More information about the pygtk mailing list