It doesn't make sense for a signal handler to return the value, return it where?
The signal handler should be a method of a class where it makes sense to store the value as an attribute, ie:
class SomeClass:
def __init__(self):
self.value = None
...
someTextView = build_textview("some text")
...
tree_selection = someTreeView.get_child().get_selection()
tree_selection.connect("changed", self.selection_changed)
...
def selection_changed(self, widget, data=None):
(model, pathlist) = widget.get_selected_rows()
for path in pathlist :
tree_iter = model.get_iter(path)
value = model.get_value(tree_iter,0)
this.value = value
return
Notes:
__init__
method declares value attribute- in connect method change
self.selection_changed()
forself.selection_changed
so you pass the method itself and not the method's result. selection_changed
method stores the value in the attribute and returns nothing.
Hope it helps.
Update
If you still feel your code will look nicer if it explicitly shows where it's storing the value, you could do something like this:
def __init__(self):
self.value = None
...
someTextView = build_textview("some text")
...
def selection_changed_handler(widget, data):
value = self.selection_changed(widget, data)
tree_selection = someTreeView.get_child().get_selection()
tree_selection.connect("changed", selection_changed_handler)
...
But I think the first one is the standard approach.