Grid layout
 
 
 

GridLayout gives more flexibility to layout control since you can do layout according to grid coordinates, but at the price of more complexity.

When you add a control to this layout you specify at which row and column to add it. When the layout is recomputed, the number of rows and columns is checked, as are their configuration (whether fixed-size or ratio). Controls are then placed accordingly, and fit to the grid. A control can span multiple rows or columns with the function add_range.

When using a GridLayout it is always a good idea to sketch the look of the controls to understand where they will be placed in the grid. It also helps to decide the different attributes of rows and columns.

The code sample TutorialGrid.py shows how to build a small OK/Cancel Tool that allows us to enter text in a memo.

Execute the script and note that when you resize the dialog, the OK and Cancel buttons are right-justified and the memo always stretches to take all available space.