Hi root!
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) )
HTH
Martin
root wrote:
>
> Hi:
>
> I want to obtain the selected item of a list, but I don't know
> correctly. I don't do it correctly. I have this code but he is
> incorrect:
>
> list = GtkList()
> list.set_selection_mode(SELECTION_SINGLE)
>
> ...
>
> def handler(_list, list=list):
> myItem = list.get_selection()
> print myItem
>
> ...
>
> list.connect("select_child", handler)
>
> I obtain this error:
>
> Traceback (innermost last):
> File "/usr/lib/python1.5/site-packages/gtk.py", line 125, in __call__
> ret = apply(self.func, a)
> File "./manejadores.py", line 233, in handler
> myItem = list.get_selection()
> File "/usr/lib/python1.5/site-packages/gtk.py", line 75, in
> __getattr__
> raise AttributeError, attr
> AttributeError: get_selection
>
> Why? Why? Why?
>
> Thanks. Javi Román.
>
> _______________________________________________
> 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