Packing Widgets

Table of Contents

Packing basics
Boxes - GtkHBox and GtkVBox
Tabular layout with GtkTable
Fixed layout


This tutorial shows the various methods to arrange widgets in a window, and tells you how to choose the right one.

If you previously did your GUIs in Visual Basic or Visual C++, you will wonder why you'd need a tutorial on widget placement. Until now it was like this: Size the window, select a widget and position it at a (x,y) position and make it this wide and that high - nothing more, totally easy. You have fixed positions and sizes, but they stay on their place even when the window size is changed - they don't adjust themselves because they don't know how.

In Gtk, things are dynamic: Widgets adjust their sizes when the window size changes, except you explicitely tell them not to do so. Setting things up is a bit more complicated than just fixing sizes and positions, but you are rewarded with a flexible window that can be sized to nearly any size, while still looking good.