2.2.6. Grid Layout (layout.managers.grid)

class layout.managers.grid.GridLM(margin=0, outside_margin=0)

Bases: layout.managers.root.LayoutManager

Lays out elements in a grid with flexible sized rows and columns.

add_element(element, col, row, cols=1, rows=1)

Adds the given element to the given position in the grid, with the given size. There is no limit to the number of elements that can be assigned to the same cell(s).

add_rule(start_col, start_row, end_col, end_row, width=0.5, color=(0, 0, 0))

Adds a rule to the grid. The row and column numbers are those on the top left of the corresponding cell in the grid. So if the grid is 10x10, then the right hand edge of the grid will be column 10, and the bottom will be column 10. In other words there is one more rule-row and column than there are cell rows and columns.

get_minimum_size(data)

Finds the minimum size of the grid.

render(rect, data)

Draws the cells in grid.

class layout.managers.grid.SimpleGridLM(columns=1, rows=1, margin=0, elements=[])

Bases: layout.managers.root.GroupLayoutManager

A simple grid takes a number of elements and arranges them in rows and columns so that each element is the same size.

calculate_columns()

Assuming the number of rows is constant, work out the best number of columns to use.

calculate_rows()

Assuming the number of columns is constant, work out the best number of rows.

get_minimum_size(data)

How small can the element be? Should return a Point.

render(rectangle, data)

Asks the element to render itself.