Automatic size of GTK+ main window

Stuart Jansen sjansen at
Tue Jan 26 10:25:44 MST 2010

On Tue, 2010-01-26 at 10:04 -0700, Charles Curley wrote:
> I'm working on a small GTK+ program to display data. It uses several
> text entry widgets with appropriate labels. The user can change the font
> in the text entry widgets. If the user selects a larger font, the text
> entry widgets and the main window all grow appropriately. If the user
> selects a smaller font, the text entry widgets shrink appropriately but
> the main window does not. What do I do to get the main window to shrink
> appropriately?

The bad news is, you're going to have to connect an appropriate signal
handler and do the resize yourself. The good news is, it's not too hard.

If you layout is simple, you can do win.resize(1, 1) and GTK+ will
automatically pick an appropriate size.

One of my apps has a slightly more complicated layout. It contains a
ScrolledWindow that will happily shrink smaller than I want, so instead
I do win.resize(*self.scrolled_child.get_size_request())

"XML is like violence: if it doesn't solve your problem, you aren't
using enough of it." - Chris Maden

More information about the PLUG mailing list