AGW Logo

agw_title BoxSizer

Pseudo-class that imitates wx.BoxSizer.

hierarchy Inheritance Diagram

Inheritance diagram for: BoxSizer

Inheritance diagram of BoxSizer

supclasses Known Superclasses

method_summary Methods Summary

__init__Constructor for BoxSizer.
AddAppends a child item to the sizer.
InsertInserts a child item into the sizer.
LayoutCall this to force layout of the children anew, e.g.
PrependPrepends a child item to the sizer.
RemoveRemoves an item from the sizer and destroys it.
ShowShows or hides the sizer item.


class BoxSizer(Sizer, wx.BoxSizer)[source]

Pseudo-class that imitates wx.BoxSizer.


Constructor for BoxSizer.

Parameters:orient (integer) – may be one of wx.VERTICAL or wx.HORIZONTAL for creating either a column sizer or a row sizer.

Add(item, proportion=0, flag=0, border=0, userData=None)[source]

Appends a child item to the sizer.

  • item – the item to be added to BoxSizer. Can be an instance of wx.Window, wx.Sizer or a spacer;
  • proportion (integer) – this parameter is used in BoxSizer to indicate if a child of a sizer can change its size in the main orientation of the BoxSizer - where 0 stands for not changeable and a value of more than zero is interpreted relative to the value of other children of the same BoxSizer. For example, you might have a horizontal BoxSizer with three children, two of which are supposed to change their size with the sizer. Then the two stretchable windows would get a value of 1 each to make them grow and shrink equally with the sizer’s horizontal dimension.
  • flag (integer) – this parameter can be used to set a number of flags which can be combined using the binary OR operator |. Two main behaviours are defined using these flags. One is the border around a window: the border parameter determines the border width whereas the flags given here determine which side(s) of the item that the border will be added. The other flags determine how the sizer item behaves when the space allotted to the sizer changes, and is somewhat dependent on the specific kind of sizer used:

    integer parameter settings
    Sizer Flag Description
    wx.TOP These flags are used to specify which side(s) of the sizer item the border width will apply to.
    wx.EXPAND The item will be expanded to fill the space assigned to the item.
    wx.SHAPED The item will be expanded as much as possible while also maintaining its aspect ratio
    wx.FIXED_MINSIZE Normally wx.Sizers will use wx.Window.GetAdjustedBestSize to determine what the minimal size of window items should be, and will use that size to calculate the layout. This allows layouts to adjust when an item changes and its best size becomes different. If you would rather have a window item stay the size it started with then use wx.FIXED_MINSIZE.
    wx.RESERVE_SPACE_EVEN_IF_HIDDEN Normally wx.Sizers don’t allocate space for hidden windows or other items. This flag overrides this behavior so that sufficient space is allocated for the window even if it isn’t visible. This makes it possible to dynamically show and hide controls without resizing parent dialog, for example. This function is new since wxWidgets version 2.8.8
    wx.ALIGN_CENTER or wx.ALIGN_CENTRE The wx.ALIGN* flags allow you to specify the alignment of the item within the space allotted to it by the sizer, adjusted for the border if any.
  • border (integer) – determines the border width, if the flag parameter is set to include any border flag.
  • userData (object) – Allows an extra object to be attached to the sizer item, for use in derived classes when sizing information is more complex than the proportion and flag will allow for.


there is no support for userData parameter if item is a pseudocontrol, since that is already used.

Insert(before, item, proportion=0, flag=0, border=0, userData=None, realIndex=None)[source]

Inserts a child item into the sizer.

See also

Add method for an explanation of the input parameters.


Call this to force layout of the children anew, e.g. after having added a child to or removed a child (window, other sizer or space) from the sizer while keeping the current dimension.

Prepend(item, proportion=0, flag=0, border=0, userData=None)[source]

Prepends a child item to the sizer.

See also

Add method for an explanation of the input parameters.

Remove(indx, pop=-1)[source]

Removes an item from the sizer and destroys it.

This method does not cause any layout or resizing to take place, call BoxSizer.Layout() to update the layout on screen after removing a child from the sizer.

  • indx (integer) – the zero-based index of an item to remove;
  • pop (bool) – whether to remove the sizer item from the list of children.

Show(item, show=True)[source]

Shows or hides the sizer item.

  • item – the sizer item we want to show/hide;
  • show (bool) – True to show the item, False to hide it.

Table Of Contents

Previous topic


Next topic