[pygtk] Inconsistent format for "path" in TreeView callbacks
Neil Muller
drnlmuller+gtk at gmail.com
Sat May 7 02:30:14 WST 2011
On 6 May 2011 18:59, Jason Heeris <jason.heeris at gmail.com> wrote:
> I have a TreeView with rows that show parameters related to a
> particular object. When the user clicks the CellRendererToggle, it
> sets a flag in that underlying object; when the row is double-clicked,
> another dialog pops up with more detail about the object.
>
> The only way I've thought to do this is to keep a dict mapping paths
> in the TreeModel to the objects. If there's a better way, I wouldn't
> shoot it down :)
Are you writing your own TreeModel (using GenericTreeModel) or using
something like TreeStore?
I think you really should be using TreeIters rather than paths to
manage this mapping, since they directly map to rows in the model,
rather than positions in the treeview which may or may not match rows
in the model.
TreeStore TreeIters (and GenericTreeModel TreeIters if you're careful)
are also preserved across operations like sorting the Treeview, which
allows you to more flexibility in the future.
Since you can trivially go from either path format to the correct
TreeIter using get_iter(path), this also removes any need to worry
about the path format.
--
Neil Muller
drnlmuller at gmail.com
I've got a gmail account. Why haven't I become cool?
More information about the pygtk
mailing list