I’m trying to use Gtk.Viewport appended inside a Gtk.Box, but when I try to, the size of the widget still makes the entire window larger, instead of the single box being scrollable.
I’ve tried searching everywhere online, but they all say to use “Gtk.ScrollableWindow”. But the problem is, I don’t want the entire window to be scrollable. And besides, because it’s a top-level widget, it can’t be appended into a Gtk.Box.
Is there any way to implement a scrollable Gtk.Box using Gtk.Viewport without Gtk.ScrollableWindow?
The reason I ask, is because I’m implementing a GridView list inside of a single scrollable box, and I really don’t know how to implement it properly.
A GtkScrolledWindow is not a window—that’s just some unfortunate naming that we’ve been stringing along for three major releases. A scrolled window is just a widget that you put into your widget tree, and provides a scrollable region for its contents.
If you want to scroll a box, you put the box into a GtkScrolledWindow widget.
Been battling away with the Columnview / Gridview and have found both totally undocumented (maybe used as well) and have been pulling out my hair trying to figure out how to simply read database contents into it.
ebassi is correct you need to use the Gtk.ScrollableWindow which is a scrollable widget, set’s its size and add a Gtk.Grid widget to that.
Ah I see, so it’s not a top-level widget. That makes sense, it provides a scrollable region for the contents.
That explains it really well, and as a result, I’ve got it working now. So now I can continue with implementing the grid list that I need to implement.
Someone should mention to the GyGObject folks to get on with some decent documentation and working examples. I wasted a considerable amount of time attempting to implement a simple grid widget using the Gridview / Columnview which I solved in 30 minutes with a ScrolledWindow widget containing a Grid widget. I find the Gtk4 API Reference is only useful for Developers that are already experienced with using its widgets… as it states Reference.