In my GTK3 window I have a Treeview with many items, so I have make it scrollable. I'm using a Scrolledwindow for that:
self.codes = Gtk.Treeview()
codeswindow = Gtk.ScrolledWindow()
codeswindow.add_with_viewport(self.codes)
codeswindow.show()
When running the application and selecting an item ("selection_changed" event) the Treeview will jump to the top, so the selected item will be out of sight. The same happens when double clicking an item for editing it. After selecting an item I then have to scroll down to the selected item.
How do I prevent this?
Maybe related: When selecting items using Arrow up
or Arrow down
the window is not scrolling along.
Like suggested in the comment by @Aran-Fey Treeview can scroll natively and quote from documentation:
and by the way:
Replacing
add_with_viewport
withadd
solves the problem: