I've got a Python app that uses a Gtk.Notebook
widget to display different pages. Each of these pages contain a different set of widgets, and I've noticed that the 'tallest' widget in terms of vertical space defines the overall vertical size of the notebook.
But I'd actually like my app to resize the pages to not waste vertical space, and adapt, that is, get resized to the same vertical size as the widget they contain. This resize should happen when I select each page.
Here's the sample code to generate this notebook (the example contains a widget per page for the sake of simplicity)
So in short, how can I dynamically resize notebook pages upon selecting them, so that their vertical space is adapted to be the same as their child widget?
Best Answer
I do not know a nice answer, but I have a work-around for you:
The basic idea is that you need a container widget as the parent widget in each page (do not place e.g. a label directly in the page), and you can hide/show everything except the container (If you hide the container as well, the page will disappear).
This solution should work for otherwise arbitrary widget hierarchies.
In my original answer I recorded and re-instated the requested sizes. This does not work in general, because the requested size is only a minimal size. I would have to record a maximum size, in order for this to work, though.