Phoenix Logo

phoenix_title wx.GridSizer

A grid sizer is a sizer which lays out its children in a two-dimensional table with all table fields having the same size, i.e.

the width of each field is the width of the widest child, the height of each field is the height of the tallest child.


class_hierarchy Class Hierarchy

Inheritance diagram for class GridSizer:

sub_classes Known Subclasses

wx.FlexGridSizer


method_summary Methods Summary

__init__ wx.GridSizer constructors.
CalcMin This method is abstract and has to be overwritten by any derived class.
CalcRowsCols CalcRowsCols() . (rows, cols)
GetCols Returns the number of columns that has been specified for the sizer.
GetEffectiveColsCount Returns the number of columns currently used by the sizer.
GetEffectiveRowsCount Returns the number of rows currently used by the sizer.
GetHGap Returns the horizontal gap (in pixels) between cells in the sizer.
GetRows Returns the number of rows that has been specified for the sizer.
GetVGap Returns the vertical gap (in pixels) between the cells in the sizer.
RecalcSizes This method is abstract and has to be overwritten by any derived class.
SetCols Sets the number of columns in the sizer.
SetHGap Sets the horizontal gap (in pixels) between cells in the sizer.
SetRows Sets the number of rows in the sizer.
SetVGap Sets the vertical gap (in pixels) between the cells in the sizer.

api Class API



class wx.GridSizer(Sizer)

Possible constructors:

GridSizer(cols, vgap, hgap)

GridSizer(cols, gap=Size(0,0))

GridSizer(rows, cols, vgap, hgap)

GridSizer(rows, cols, gap)

A grid sizer is a sizer which lays out its children in a two- dimensional table with all table fields having the same size, i.e.


Methods



__init__(self, *args, **kw)

wx.GridSizer constructors.

Usually only the number of columns in the flex grid sizer needs to be specified using cols argument. The number of rows will be deduced automatically depending on the number of the elements added to the sizer.

If a constructor form with rows parameter is used (and the value of rows argument is not zero, meaning “unspecified”) the sizer will check that no more than cols*rows elements are added to it, i.e. that no more than the given number of rows is used. Adding less than maximally allowed number of items is not an error however.

Finally, it is also possible to specify the number of rows and use 0 for cols. In this case, the sizer will use the given fixed number of rows and as many columns as necessary.

The gap (or vgap and hgap, which correspond to the height and width of the wx.Size object) argument defines the size of the padding between the rows (its vertical component, or vgap) and columns (its horizontal component, or hgap), in pixels.

New in version 2.9.1: (except for the four argument overload)

overload Overloaded Implementations:



__init__ (self, cols, vgap, hgap)

Parameters:
  • cols (int) –
  • vgap (int) –
  • hgap (int) –



__init__ (self, cols, gap=Size(0,0))

Parameters:



__init__ (self, rows, cols, vgap, hgap)

Parameters:
  • rows (int) –
  • cols (int) –
  • vgap (int) –
  • hgap (int) –



__init__ (self, rows, cols, gap)

Parameters:
  • rows (int) –
  • cols (int) –
  • gap (wx.Size) –





CalcMin(self)

This method is abstract and has to be overwritten by any derived class.

Here, the sizer will do the actual calculation of its children’s minimal sizes.

Return type: wx.Size


CalcRowsCols(self)

Calculates how many rows and columns will be in the sizer based on the current number of items and also the rows, cols specified in the constructor.



GetCols(self)

Returns the number of columns that has been specified for the sizer.

Returns zero if the sizer is automatically adjusting the number of columns depending on number of its children. To get the effective number of columns or rows being currently used, see GetEffectiveColsCount

Return type:int


GetEffectiveColsCount(self)

Returns the number of columns currently used by the sizer.

This will depend on the number of children the sizer has if the sizer is automatically adjusting the number of columns/rows.

Return type:int

New in version 2.9.1.



GetEffectiveRowsCount(self)

Returns the number of rows currently used by the sizer.

This will depend on the number of children the sizer has if the sizer is automatically adjusting the number of columns/rows.

Return type:int

New in version 2.9.1.



GetHGap(self)

Returns the horizontal gap (in pixels) between cells in the sizer.

Return type:int


GetRows(self)

Returns the number of rows that has been specified for the sizer.

Returns zero if the sizer is automatically adjusting the number of rows depending on number of its children. To get the effective number of columns or rows being currently used, see GetEffectiveRowsCount .

Return type:int


GetVGap(self)

Returns the vertical gap (in pixels) between the cells in the sizer.

Return type:int


RecalcSizes(self)

This method is abstract and has to be overwritten by any derived class.

Here, the sizer will do the actual calculation of its children’s positions and sizes.



SetCols(self, cols)

Sets the number of columns in the sizer.

Parameters:cols (int) –


SetHGap(self, gap)

Sets the horizontal gap (in pixels) between cells in the sizer.

Parameters:gap (int) –


SetRows(self, rows)

Sets the number of rows in the sizer.

Parameters:rows (int) –


SetVGap(self, gap)

Sets the vertical gap (in pixels) between the cells in the sizer.

Parameters:gap (int) –

Properties



Cols

See GetCols and SetCols



EffectiveColsCount

See GetEffectiveColsCount



EffectiveRowsCount

See GetEffectiveRowsCount



HGap

See GetHGap and SetHGap



Rows

See GetRows and SetRows



VGap

See GetVGap and SetVGap