Automatic size of GTK+ main window
charlescurley at charlescurley.com
Tue Jan 26 18:00:43 MST 2010
On Tue, 26 Jan 2010 10:25:44 -0700
Stuart Jansen <sjansen at buscaluz.org> wrote:
> 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
Well, I already have a signal handler for the OK and APPLY buttons on
the font dialog, and I do all the work there.
> If you layout is simple, you can do win.resize(1, 1) and GTK+ will
> automatically pick an appropriate size.
I'm working in C rather than C++ or Python, so I assume that your
win.resize() maps to gtk_window_resize (). After the code to change the
style of all the widgets, I added:
gtk_window_resize (GTK_WINDOW (window), 1, 1);
This does not appear to make any difference, either going to a larger
font (which works anyway) or to a smaller font (which doesn't work
> 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())
I was hoping to avoid a mess of doing that.
I have the main window. Inside that I have a vbox. In that I have, from
top to bottom, a menubar (with nested menu entries), and a table.
Inside the table I have six pair of text entry boxes and labels (in a
two by three grid), and a progress bar. I set the fonts only on the six
text entry boxes and the progress bar. I leave the menus and the labels
So I gather getting the size requests would involve walking the entire
mess and summing the requests, and then presenting the result to the
window with gtk_window_resize ().
Charles Curley /"\ ASCII Ribbon Campaign
Looking for fine software \ / Respect for open standards
and/or writing? X No HTML/RTF in email
http://www.charlescurley.com / \ No M$ Word docs in email
Key fingerprint = CE5C 6645 A45A 64E4 94C0 809C FFF6 4C48 4ECD DFDB
More information about the PLUG