Editable lists in pygtk - Editing wrong cell

sapo fabioxgn at gmail.com
Sat Feb 25 15:14:34 EST 2006


Hi all, i m trying to make an editable list with a toggle button, it
shows up and i can edit the list.. but its editing the wrong cell!

If i click on the toggle button on the first cell it sets FALSE on the
last cell of that row, if i change the text of the last cell if changes
another cell text... here is my code:

    tree = self.principal.get_widget("file_list")
    list = gtk.ListStore(str, str)
    #Permite selecionar os arquivos
    toggle = gtk.CellRendererToggle()
    toggle.set_property('activatable', True)
    tree.insert_column_with_attributes(-1, "Convert?", toggle)
    toggle.connect('toggled', self.Select, tree)
    #permite editar a lista
    renderer = gtk.CellRendererText()
    renderer.set_property( 'editable', True )
    renderer.connect('edited', self.Edit, list)
    tree.insert_column_with_attributes(-1, "Artist", renderer, text=0)
    tree.insert_column_with_attributes(-1, "Song", renderer, text=1)
    tree.set_model(list)

  def Select(self,cell,path,model):
    model[path][1] = not model[path][1]
    return
  def Edit(self, cell, path, new_text, model):
    model[path][0] = new_text

What's wrong with it? i m following this example:
http://pygtk.org/pygtk2tutorial/sec-CellRenderers.html#EditableTextCells

thanx in advance




More information about the Python-list mailing list