0

I have this Gtk.TreeView()

treeview = Gtk.TreeView(model=liststore)

And I get the selected item like this:

selected_playlist_item = treeview.get_selection()
selected_playlist_item.connect("changed", self.on_selected_playlist_item)

And here is the on_selected_playlist_item callback

def on_selected_playlist_item(self, selection):
    model, treeiter = selection.get_selected()
    if treeiter is not None:
        print("You selected", model[treeiter][1])

How can I connect only to the double-click / return selection, and not just a single click / movement in the listview?

I have been looking in a lot of places for a list of possible signals, but to no avail ; If somebody knows where to find such documentation, that would be a nice bonus, I have other connect() issues like that.

yPhil
  • 8,049
  • 4
  • 57
  • 83

1 Answers1

1

I got the answer:

Connect the TreeView itself (not the row / selection like I was doing) to the row-activated signal:

self.treeview.connect("row-activated", self.cb)

(Click click / Return)

def cb(self, tree_view, path, column):
    print("Selected!!")
yPhil
  • 8,049
  • 4
  • 57
  • 83
  • Could explain the difference between the two methods? I would have thought they would be equivalent. Thanks. – John May 25 '23 at 21:53