Get a New Choice in GtkTreeView During Signal

I want that whenever my chooses me gtk.TreeView, and when he does this, the w / this information function is called. The only way I've found this so far is to bind to all of these signals:

...
    self.sitterView.connect("cursor-changed", self.selectionChanged)
    self.sitterView.connect("unselect-all", self.selectionChanged)
    self.sitterView.connect("toggle-cursor-row", self.selectionChanged)
    self.sitterView.connect("select-all", self.selectionChanged)    
...
def selectionChanged(self, treeview):
    foo(self.sitterView.get_selection().get_selected())

However, it seems that the choice I get from the callback is “delayed”. That is, it shows the selection after completing the previous callback. For example, if I constantly press CTRL + on a line when the line goes from selected to selected, foo gives no choice, and when the line goes from selected to deferred, it is assigned a choice. If I call a get_selection().get_selected()second later, I get the right choice. Any idea how to handle this?

+5
source share
1 answer

I'm not sure what it does toggle-cursor-row(the documentation disappoints empty), but I think that the wrong signal to process.

Instead, you should connect to the GtkTreeSelection signal changed. He should take care of all the events of the change of choice, so you do not need to connect to other signals as well.

+6
source

All Articles