[pygtk] Re: Trouble getting a ListStore with dynamic column number.

Michael Urman murman at gmail.com
Mon Feb 4 04:32:52 WST 2008


On Feb 3, 2008 12:58 PM, Alessandro Dentella <sandro at e-den.it> wrote:
> This is an interesting solution. I'm just worried about efficency and I'd
> like if someone could comment on this.

Quod Libet uses this style (single-column model with cell-data-funcs)
to display a user-configurable set of music metadata columns and it
doesn't have serious performance setbacks even with thousands of rows.
To keep it fast, make sure your callbacks are as fast as feasible
(they are hit a lot), and use the tree view's fixed-height option so
it doesn't have to size every row to draw the scrollbar appropriately.

> When is an advantage and when is better to set directly the value in the
> model?

If you have to do serious calculation in what could be a
cell-data-func, it's probably better to do it elsewhere and cache it.
Whether you cache it in a model or on a python instance and just use a
simpler cell-data-func depends on your scenario.

Personally I'm torn on whether to use it when you are setting visual
properties of the rows. There's something elegant of not needing to
set the visual properties via function in each cell, but at the same
time having to remember that your editability is stored in column 3
and strikethrough is in column 5, etc., negates the elegance pretty
fast.

-m
-- 
Michael Urman


More information about the pygtk mailing list