[pygtk] TreeView: model-unrelated editability?
John Finlay
finlay at moeraki.com
Mon May 1 04:17:15 WST 2006
Alan Franzoni wrote:
> Hello!
> I have a problem with a TreeView. I want individual cells to be set
> editable or non-editable on a per-row and per-column basis: if both the
> column and the row where the cell is are editable, then the cell is
> editable as well; otherwise, it is not.
>
> Now, I've checked the pygtk faq, and it's suggested I should add a bool
> column to my model and set the 'editable' attribute of TreeViewColumn to
> that column. I don't like that solution, because it forces me to add a
> column in my model that I don't want.
>
> Of course I could just use a new CellRendererText instance for every cell,
> but I think this could be a bit unmanageable and could lead to memory
> occupation grow out of control (not tested, though). Is there any other
> effective way to do it?
>
>
You could set a cell data function to set the attributes of the cell to
whatever you want though this might be slow for large TreeViews. See the
Reference;
http://pygtk.org/pygtk2reference/class-gtktreeviewcolumn.html#method-gtktreeviewcolumn--set-cell-data-func
and the Tutorial:
http://pygtk.org/pygtk2tutorial/sec-CellRenderers.html#sec-CellDataFunction
John
More information about the pygtk
mailing list