Get selected object from TreeView
- by GoGoDo
I've been working on a minor (first time) app with quickly and hit a hurdle - how do I get the selected row (the data) from a TreeView? The data to the TreeView is passed from a list of files in a directory, and I need to know which rows were selected (and thus which files were). What is the best way to do that?
Here's the current code:
self.treeview = self.builder.get_object("treeview")
select = self.treeview.get_selection()
select.connect("changed", self.on_tree_selection_changed)
def on_tree_selection_changed(selection):
model, treeiter = self.treeview.selection-get()
if treeiter != None:
print "You selected", model[treeiter][0]