I'm using Python3 and Gtk+3. When I add a new row to my Gtk.TreeView, these are always appended at the end. I want whenever I add a new row to set the cursor on it. I know I have to use the "set_cursor()" function, or at least I think so. However, I don't know how to retrieve the path of the row.
I am using the signal size-allocate, which tells me when there are changes in my Gtk.TreeView.
self.treeview.connect('size-allocate', self.on_treeview_size_changed)
def on_treeview_size_changed(self, widget, allocation):
self.treeview.set_cursor(path, None, False)
Any ideas how can I retrieve the path of the last row or make what I am trying to do happen?
This is what I use:
last = self.store.iter_n_children ()
last = last -1 #iter_n_children starts at 1 ; set_cursor starts at 0
c = self.treeview.get_column(0)
self.treeview.set_cursor(last , c, True) #set the cursor to the last appended item
Basically, get the row count of the store, subtract 1 and set the cursor to that row.