Aaron, 

Thanks for the code reduction (10 to 1!!)

Martin.

Aaron Optimizer Digulla wrote:
> 
> Quoting Martin Franklin <[EMAIL PROTECTED]>:
> 
> > I had this problem the other day and came up with BTW i'm using a
> > Clist...
> >
> > .......cut.......
> >         self.selected=[]
> >
> >         self.clist = GtkCList(3,['One','Two', 'Three'] )
> >         self.clist.connect("select_row", self.select_list)
> >         self.clist.connect("unselect_row", self.deselect_list)
> >         self.clist.connect("click-column", self.col_click)
> >
> > ........cut......
> >
> >
> >     def get_selected(self, *stuff):
> >         return self.selected
> >
> >     def select_list(self, *stuff):
> >         id = self.clist.get_text(stuff[1], 0)
> >         cd = self.clist.get_text(stuff[1], 1)
> >         dc = self.clist.get_text(stuff[1], 2)
> >         self.selected.append( (id, cd, dc) )
> >
> >     def deselect_list(self, *stuff):
> >         id = self.clist.get_text(stuff[1], 0)
> >         cd = self.clist.get_text(stuff[1], 1)
> >         dc = self.clist.get_text(stuff[1], 2)
> >         self.selected.remove( (id, cd, dc) )
> 
> Just try clist.selection, that contains a list with the row numbers of
> the currently selected items.
> 
> Something else: When you add callbacks for (un)select_row, then
> select_all/unselect_all can become very slow if your list has
> several thousand rows (because you're signaled for every row).
> The solution is to create an idle callback:
> 
>    def select_row (self, *args):
>       if self.idle == -1:
>          self.idle = idle_add (self.selection_changed)
> 
>    def selection_changed (self, *args):
>        self.idle = -1
>        ...
> 
> --
> ==============================================
> Sowatec AG,       CH-8330 Pfäffikon (ZH)
> Witzbergstr. 7,   http://www.sowatec.com
> Tel: +41-(0)1-952 55 55
> Fax: +41-(0)1-952 55 66
> ----------------------------------------------
> Aaron "Optimizer" Digulla, [EMAIL PROTECTED]
> ==============================================
> 
> _______________________________________________
> pygtk mailing list   [EMAIL PROTECTED]
> http://www.daa.com.au/mailman/listinfo/pygtk

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to