Search code examples
pythoncgtkpygobjectgtktreeview

Gtk.Treeview deselect row via signals and code


I'm using PyGObject but I think this is a question that could be adapted to all GTK, so if someone know how to do it using C or anything should work in python also.

I have two treeview, Active and Inactive, I load data from a Sqlite database and I can swap and drag & drop items from one to other. This is just an aestetic thing, if I click on one item on one treeview I want that a previous selected item on the other be deselected.

It appears that nobody had to do something similar because I didn't found anything about it on the net.


Solution

  • At the risk of being too basic (perhaps I misunderstand the problem), to manipulate treeview selections, you use the GtkTreeSelection object returned from GtkTreeView.get_selection. You can attach to signals on this object, change the current selection,etc.