[pygtk] Re: mark rows with pattern in treeview

Fabian Braennstroem f.braennstroem at gmx.de
Fri Mar 9 05:13:37 WST 2007


Hi John,

John Dennis schrieb am 03/06/2007 08:07 PM:
> On Tue, 2007-03-06 at 19:38 +0000, Fabian Braennstroem wrote:
>> Hi Yuri,
>>
>> Yuri Pimenov schrieb am 03/06/2007 09:26 AM:
>>> use TreeViewColumn's set_cell_data_func() to set attributes
>>> the way you like.
>> I think you misunderstood me; I am writing a small file manager
>> based on the example from the tutorial and try to find a way to
>> select (or mark) e.g. all files with the pdf-extension.
>> One way would be to use a for loop to search in the 'list' for all
>> pdf files and keep the corresponding row number; but I am not sure
>> which function to use for selection!?
> 
> First get the selection object from the treeview:
> selection = treeview.get_selection()
> 
> Then select the each path or iter (depending if you're using paths or
> iters)
> 
> selection.select_path(some_path)
> or
> selection.select_iter(some_iter)
> 
> You'll probably end up with something like this:
> 
> selection.unselect_all()
> iter = model.get_iter_first()
>   while iter:
>     value = model.get_value(iter, column)
>     if value is what I'm looking for:
>         selection.select_iter(iter)
>     iter = model.iter_next(iter)

Thanks! Works really nice with path :-)

Greetings!
Fabian



More information about the pygtk mailing list