I have created a simple treestore, with each node containing two strings, ie:

   self.wTreeModel = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)

and allowed multiple selection with:

   self.wTreeSelection = self.wTreeView.get_selection()
   self.wTreeSelection.set_mode(gtk.SELECTION_MULTIPLE)

and then populated it with something like:

   child = self.wTreeModel.append(parent, [ <a string to display on
the tree>, <some data associated with that row> ])

all well and good; the tree shows up correctly in the window.

But now I want to be able to select one or more of the rows in the
tree, then get back the <some data> associated with each row.  I have
tried something like:

        treeSelection = self.wTreeView.get_selection()
        model, selected = treeSelection.get_selected_rows()
        for path in selected:
            for i in range(len(path)):
                it = model.get_iter(path[i])
                print model[it][1]

which I feel should print the <some data> for each selected row, but
what actually comes out seems largely unrelated to what has been
selected.  So for instance, given a tree:

one --
      |-- two --
                |-- three

I should be able to select "three" and get back the data associated
with it.  What I actually get back from the above bit of code is the
data associated with "one", three times.

Any help would be greatly appreciated!


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

Reply via email to