Here's the scenario: I have two gtk.TreeViews that are essentially
handled by the same code.  Attached to each are two columns, one with
toggles (which use a dict for a data store instead of a gtk.TreeStore
for a variety of reasons that I hope aren't pertinent) and the other
with text.  I made the text editable, which means that whenever the text
is changed I need to change the dicts to reflect that change (I don't
think this is related to the problem, just giving some background).  And
the problem: For some reason, one of the treeviews (one which functions
like a listview - there are no child nodes) behaves normally when
edited, but the other one (this one has child nodes) creates a duplicate
node whenever I edit a node (although if the node has children, it the
duplicate node will not have children).  So, for example, if I click on
the first node and rename it to "test", I end up with two nodes named
"test".  This happens whether or not the node I rename has children.
Right now, I'm stumped.  Any suggestions?

Here's the callback that responds to the "text-edited" signal:

        def text_edited_cb(self, text, path, new_text, column):
                #get an iterator
                my_iter = self.model.get_iter(path)
                #update the dict that stores the bool values
                old_text = self.model.get_value(my_iter, 0)
                old_value = self.bool_list[old_text]
                del self.bool_list[old_text]
                self.bool_list.update({new_text : old_value})
                #if there's a secondary list, update it too
                if self.extra_list != None:
                        old_extra = self.extra_list[old_text]
                        self.extra_list.update({new_text : old_extra})
                        del self.extra_list[old_text]
                        if self.extra_list[new_text].get_text() == old_text:
                                self.extra_list[new_text].set_text(new_text)
                #and, actually change the text
                self.model.set_value(my_iter, 0, new_text)

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to