[pygtk] Simplifying what's stored in a ListStore (was Re: Inconsistent format for "path" in TreeView callbacks)
Alessandro Dentella
sandro at e-den.it
Sat May 7 16:04:32 WST 2011
On Sat, May 07, 2011 at 12:39:01PM +0800, Jason Heeris wrote:
> On 7 May 2011 03:24, Neil Muller <drnlmuller+gtk a gmail.com> wrote:
> > On 6 May 2011 21:07, Jason Heeris <jason.heeris a gmail.com> wrote:
> > Storing the object in a hidden column is fine, and what I assumed you
> > were doing originally.
>
> Hah! Okay then, now that it's morning, I can't believe that didn't
> occur to me :P
>
> While we're on the topic though, it strikes me as more sensible to
> simply put the objects themselves in a ListStore without manually
> extracting the information for the other columns (ie. so the ListStore
> just contains one column, which is displayed in different ways). Is
> there a way to tell each TreeViewColumn to, say, "look at column zero,
> take the x.fit.param_A attribute, format it using "0x%03X and display
> it in a CellRendererText" — and then so on for each attribute, each
> describing to a different view of the same column?
Sure, you can use column's set_cell_data_function's method to sett cell's
property values as you prefere. These functions will be called pretty
frequently, each time a cell's area is redrawn, but it's not called for not
visible cell's -as far as I understood-. That means it can be faster or
slower that a pre-process in which you set all item's in advance in each
column.
I use this method in sqlkit and you can have a look here [1] to see several
different cell_data_functions for different data types.
sandro
*:-)
[1] http://hg.argolinux.org/py/sqlkit/file/tip/sqlkit/widgets/table/columns.py
--
Sandro Dentella *:-)
http://www.reteisi.org Soluzioni libere per le scuole
http://sqlkit.argolinux.org SQLkit home page - PyGTK/python/sqlalchemy
More information about the pygtk
mailing list