Phoenix Logo

phoenix_title wx.Sizer

wx.Sizer is the abstract base class used for laying out subwindows in a window.

You cannot use wx.Sizer directly; instead, you will have to use one of the sizer classes derived from it. Currently there are wx.BoxSizer, wx.StaticBoxSizer, wx.GridSizer, wx.FlexGridSizer, wx.WrapSizer and wx.GridBagSizer.

The layout algorithm used by sizers in wxWidgets is closely related to layout in other GUI toolkits, such as Java’s AWT, the GTK toolkit or the Qt toolkit. It is based upon the idea of the individual subwindows reporting their minimal required size and their ability to get stretched if the size of the parent window has changed.

This will most often mean that the programmer does not set the original size of a dialog in the beginning, rather the dialog will be assigned a sizer and this sizer will be queried about the recommended size. The sizer in turn will query its children, which can be normal windows, empty space or other sizers, so that a hierarchy of sizers can be constructed. Note that wx.Sizer does not derive from wx.Window and thus does not interfere with tab ordering and requires very little resources compared to a real window on screen.

What makes sizers so well fitted for use in wxWidgets is the fact that every control reports its own minimal size and the algorithm can handle differences in font sizes or different window (dialog item) sizes on different platforms without problems. If e.g. the standard font as well as the overall design of Motif widgets requires more space than on Windows, the initial dialog size will automatically be bigger on Motif than on Windows.

Sizers may also be used to control the layout of custom drawn items on the window. The wx.Sizer.Add , wx.Sizer.Insert , and wx.Sizer.Prepend functions return a pointer to the newly added wx.SizerItem. Just add empty space of the desired size and attributes, and then use the wx.SizerItem.GetRect method to determine where the drawing operations should take place.

Please notice that sizers, like child windows, are owned by the library and will be deleted by it which implies that they must be allocated on the heap. However if you create a sizer and do not add it to another sizer or window, the library wouldn’t be able to delete such an orphan sizer and in this, and only this, case it should be deleted explicitly.

phoenix_title Sizer flags

The “flag” argument accepted by wx.SizerItem constructors and other functions, e.g. wx.Sizer.Add , is an OR-combination of the following flags. 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.

Sizer Flag Description
wx.TOP
wx.BOTTOM
wx.LEFT
wx.RIGHT
wx.ALL
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.GetEffectiveMinSize 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.
wx.ALIGN_CENTER or wx.ALIGN_CENTRE
wx.ALIGN_LEFT
wx.ALIGN_RIGHT
wx.ALIGN_RIGHT
wx.ALIGN_TOP
wx.ALIGN_BOTTOM
wx.ALIGN_CENTER_VERTICAL or wx.ALIGN_CENTRE_VERTICAL
wx.ALIGN_CENTER_HORIZONTAL or wx.ALIGN_CENTRE_HORIZONTAL
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.

See also

Sizers Overview


class_hierarchy Class Hierarchy

Inheritance diagram for class Sizer:


sub_classes Known Subclasses

wx.BoxSizer, wx.GridSizer


method_summary Methods Summary

__init__ The constructor.
Add Appends a child to the sizer.
AddMany AddMany is a convenience method for adding several items to a sizer
AddSpacer This base function adds non-stretchable space to both the horizontal and vertical orientation of the sizer.
AddStretchSpacer Adds stretchable space to the sizer.
CalcMin This method is abstract and has to be overwritten by any derived class.
Clear Detaches all children from the sizer.
ComputeFittingClientSize Computes client area size for window so that it matches the sizer’s minimal size.
ComputeFittingWindowSize Like ComputeFittingClientSize , but converts the result into window size.
Detach Detach the child window from the sizer without destroying it.
Fit Tell the sizer to resize the window so that its client area matches the sizer’s minimal size ( ComputeFittingClientSize is called to determine it).
FitInside Tell the sizer to resize the virtual size of the window to match the sizer’s minimal size.
GetChildren Returns the list of the items in this sizer.
GetContainingWindow Returns the window this sizer is used in or None if none.
GetItem Finds wx.SizerItem which holds the given window.
GetItemById Finds item of the sizer which has the given id.
GetItemCount Returns the number of items in the sizer.
GetMinSize Returns the minimal size of the sizer.
GetPosition Returns the current position of the sizer.
GetSize Returns the current size of the sizer.
Hide Hides the child window.
InformFirstDirection Inform sizer about the first direction that has been decided (by parent item).
Insert Insert a child into the sizer before any existing item at index.
InsertSpacer Inserts non-stretchable space to the sizer.
InsertStretchSpacer Inserts stretchable space to the sizer.
IsEmpty Return True if the sizer has no elements.
IsShown Returns True if the window is shown.
Layout 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 Same as Add , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.
PrependSpacer Prepends non-stretchable space to the sizer.
PrependStretchSpacer Prepends stretchable space to the sizer.
RecalcSizes This method is abstract and has to be overwritten by any derived class.
Remove Removes a sizer child from the sizer and destroys it.
Replace Detaches the given oldwin from the sizer and replaces it with the given newwin.
SetContainingWindow Set the window this sizer is used in.
SetDimension Call this to force the sizer to take the given dimension and thus force the items owned by the sizer to resize themselves according to the rules defined by the parameter in the Add and Prepend methods.
SetItemMinSize Set an item’s minimum size by window, sizer, or position.
SetMinSize Call this to give the sizer a minimal size.
SetSizeHints This method first calls Fit and then wx.TopLevelWindow.SetSizeHints on the window passed to it.
SetVirtualSizeHints Tell the sizer to set the minimal size of the window virtual area to match the sizer’s minimal size.
Show Shows or hides the window.
ShowItems Show or hide all items managed by the sizer.
__nonzero__ Can be used to test if the C++ part of the sizer still exists, with

api Class API



class wx.Sizer(Object)

Possible constructors:

Sizer()

Sizer is the abstract base class used for laying out subwindows in a window.


Methods



__init__(self)

The constructor.

Note that wx.Sizer is an abstract base class and may not be instantiated.



Add(self, *args, **kw)

overload Overloaded Implementations:



Add (self, window, flags)

Appends a child to the sizer.

wx.Sizer itself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here:

Parameters:
  • window (wx.Window) – The window to be added to the sizer. Its initial size (either set explicitly by the user or calculated internally when using DefaultSize) is interpreted as the minimal and in many cases also the initial size.
  • flags (wx.SizerFlags) – A wx.SizerFlags object that enables you to specify most of the above parameters more conveniently.
Return type:

wx.SizerItem



Add (self, window, proportion=0, flag=0, border=0, userData=None)

Appends a child to the sizer.

wx.Sizer itself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here:

Parameters:
  • window (wx.Window) – The window to be added to the sizer. Its initial size (either set explicitly by the user or calculated internally when using DefaultSize) is interpreted as the minimal and in many cases also the initial size.
  • proportion (int) – Although the meaning of this parameter is undefined in wx.Sizer, it is used in wx.BoxSizer to indicate if a child of a sizer can change its size in the main orientation of the wx.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 wx.BoxSizer. For example, you might have a horizontal wx.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 (int) – OR-combination of flags affecting sizer’s behaviour. See Sizer flags list for details.
  • border (int) – Determines the border width, if the flag parameter is set to include any border flag.
  • userData (PyUserData) – 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.
Return type:

wx.SizerItem



Add (self, sizer, flags)

Appends a child to the sizer.

wx.Sizer itself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here:

Parameters:
  • sizer (wx.Sizer) – The (child-)sizer to be added to the sizer. This allows placing a child sizer in a sizer and thus to create hierarchies of sizers (typically a vertical box as the top sizer and several horizontal boxes on the level beneath).
  • flags (wx.SizerFlags) – A wx.SizerFlags object that enables you to specify most of the above parameters more conveniently.
Return type:

wx.SizerItem



Add (self, sizer, proportion=0, flag=0, border=0, userData=None)

Appends a child to the sizer.

wx.Sizer itself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here:

Parameters:
  • sizer (wx.Sizer) – The (child-)sizer to be added to the sizer. This allows placing a child sizer in a sizer and thus to create hierarchies of sizers (typically a vertical box as the top sizer and several horizontal boxes on the level beneath).
  • proportion (int) – Although the meaning of this parameter is undefined in wx.Sizer, it is used in wx.BoxSizer to indicate if a child of a sizer can change its size in the main orientation of the wx.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 wx.BoxSizer. For example, you might have a horizontal wx.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 (int) – OR-combination of flags affecting sizer’s behaviour. See Sizer flags list for details.
  • border (int) – Determines the border width, if the flag parameter is set to include any border flag.
  • userData (PyUserData) – 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.
Return type:

wx.SizerItem



Add (self, width, height, proportion=0, flag=0, border=0, userData=None)

Appends a spacer child to the sizer.

wx.Sizer itself is an abstract class, but the parameters are equivalent in the derived classes that you will instantiate to use it so they are described here.

width and height specify the dimension of a spacer to be added to the sizer. Adding spacers to sizers gives more flexibility in the design of dialogs; imagine for example a horizontal box with two buttons at the bottom of a dialog: you might want to insert a space between the two buttons and make that space stretchable using the proportion flag and the result will be that the left button will be aligned with the left side of the dialog and the right button with the right side - the space in between will shrink and grow with the dialog.

Parameters:
  • width (int) – Width of the spacer.
  • height (int) – Height of the spacer.
  • proportion (int) – Although the meaning of this parameter is undefined in wx.Sizer, it is used in wx.BoxSizer to indicate if a child of a sizer can change its size in the main orientation of the wx.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 wx.BoxSizer. For example, you might have a horizontal wx.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 (int) – OR-combination of flags affecting sizer’s behaviour. See Sizer flags list for details.
  • border (int) – Determines the border width, if the flag parameter is set to include any border flag.
  • userData (PyUserData) – 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.
Return type:

wx.SizerItem



Add (self, width, height, flags)

Appends a spacer child to the sizer.

Parameters:
  • width (int) – Width of the spacer.
  • height (int) – Height of the spacer.
  • flags (wx.SizerFlags) – A wx.SizerFlags object that enables you to specify most of the other parameters more conveniently.
Return type:

wx.SizerItem



Add (self, item)

Parameters:item (wx.SizerItem) –
Return type: wx.SizerItem



Add (self, size, proportion=0, flag=0, border=0, /Transfer/=None)

Add a spacer using a Size object.

Return type: wx.SizerItem



Add (self, size, flags)

Add a spacer using a Size object.

Return type: wx.SizerItem





AddMany(self, items)

AddMany is a convenience method for adding several items to a sizer at one time. Simply pass it a list of tuples, where each tuple consists of the parameters that you would normally pass to the Add method.



AddSpacer(self, size)

This base function adds non-stretchable space to both the horizontal and vertical orientation of the sizer.

More readable way of calling:

wx.Sizer.Add(size, size, 0)
Parameters:size (int) –
Return type: wx.SizerItem


AddStretchSpacer(self, prop=1)

Adds stretchable space to the sizer.

More readable way of calling:

wx.Sizer.Add(0, 0, proportion)
Parameters:prop (int) –
Return type: wx.SizerItem


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


Clear(self, delete_windows=False)

Detaches all children from the sizer.

If delete_windows is True then child windows will also be deleted.

Notice that child sizers are always deleted, as a general consequence of the principle that sizers own their sizer children, but don’t own their window children (because they are already owned by their parent windows).

Parameters:delete_windows (bool) –


ComputeFittingClientSize(self, window)

Computes client area size for window so that it matches the sizer’s minimal size.

Unlike GetMinSize , this method accounts for other constraints imposed on window, namely display’s size (returned size will never be too large for the display) and maximum window size if previously set by wx.Window.SetMaxSize .

The returned value is suitable for passing to wx.Window.SetClientSize or wx.Window.SetMinClientSize .

Parameters:window (wx.Window) –
Return type: wx.Size

New in version 2.8.8.



ComputeFittingWindowSize(self, window)

Like ComputeFittingClientSize , but converts the result into window size.

The returned value is suitable for passing to wx.Window.SetSize or wx.Window.SetMinSize .

Parameters:window (wx.Window) –
Return type: wx.Size

New in version 2.8.8.



Detach(self, *args, **kw)

overload Overloaded Implementations:



Detach (self, window)

Detach the child window from the sizer without destroying it.

This method does not cause any layout or resizing to take place, call Layout to update the layout “on screen” after detaching a child from the sizer.

Returns True if the child item was found and detached, False otherwise.

Parameters:window (wx.Window) –
Return type:bool

See also

Remove



Detach (self, sizer)

Detach the child sizer from the sizer without destroying it.

This method does not cause any layout or resizing to take place, call Layout to update the layout “on screen” after detaching a child from the sizer.

Returns True if the child item was found and detached, False otherwise.

Parameters:sizer (wx.Sizer) –
Return type:bool

See also

Remove



Detach (self, index)

Detach a item at position index from the sizer without destroying it.

This method does not cause any layout or resizing to take place, call Layout to update the layout “on screen” after detaching a child from the sizer. Returns True if the child item was found and detached, False otherwise.

Parameters:index (int) –
Return type:bool

See also

Remove





Fit(self, window)

Tell the sizer to resize the window so that its client area matches the sizer’s minimal size ( ComputeFittingClientSize is called to determine it).

This is commonly done in the constructor of the window itself, see sample in the description of wx.BoxSizer.

Parameters:window (wx.Window) –
Return type: wx.Size
Returns:The new window size.


FitInside(self, window)

Tell the sizer to resize the virtual size of the window to match the sizer’s minimal size.

This will not alter the on screen size of the window, but may cause the addition/removal/alteration of scrollbars required to view the virtual area in windows which manage it.

Parameters:window (wx.Window) –


GetChildren(self)

Returns the list of the items in this sizer.

The elements of type-safe List SizerItemList are pointers to objects of type wx.SizerItem.

Return type:SizerItemList


GetContainingWindow(self)

Returns the window this sizer is used in or None if none.

Return type: wx.Window


GetItem(self, *args, **kw)

overload Overloaded Implementations:



GetItem (self, window, recursive=False)

Finds wx.SizerItem which holds the given window.

Use parameter recursive to search in subsizers too. Returns pointer to item or None.

Parameters:
  • window (wx.Window) –
  • recursive (bool) –
Return type:

wx.SizerItem



GetItem (self, sizer, recursive=False)

Finds wx.SizerItem which holds the given sizer.

Use parameter recursive to search in subsizers too. Returns pointer to item or None.

Parameters:
  • sizer (wx.Sizer) –
  • recursive (bool) –
Return type:

wx.SizerItem



GetItem (self, index)

Finds wx.SizerItem which is located in the sizer at position index.

Use parameter recursive to search in subsizers too. Returns pointer to item or None.

Parameters:index (int) –
Return type: wx.SizerItem





GetItemById(self, id, recursive=False)

Finds item of the sizer which has the given id.

This id is not the window id but the id of the wx.SizerItem itself. This is mainly useful for retrieving the sizers created from XRC resources. Use parameter recursive to search in subsizers too. Returns pointer to item or None.

Parameters:
  • id (int) –
  • recursive (bool) –
Return type:

wx.SizerItem



GetItemCount(self)

Returns the number of items in the sizer.

If you just need to test whether the sizer is empty or not you can also use IsEmpty function.

Return type:int


GetMinSize(self)

Returns the minimal size of the sizer.

This is either the combined minimal size of all the children and their borders or the minimal size set by SetMinSize , depending on which is bigger. Note that the returned value is client size, not window size. In particular, if you use the value to set toplevel window’s minimal or actual size, use wx.Window.SetMinClientSize or wx.Window.SetClientSize , not wx.Window.SetMinSize or wx.Window.SetSize .

Return type: wx.Size


GetPosition(self)

Returns the current position of the sizer.

Return type: wx.Point


GetSize(self)

Returns the current size of the sizer.

Return type: wx.Size


Hide(self, *args, **kw)

overload Overloaded Implementations:



Hide (self, window, recursive=False)

Hides the child window.

To make a sizer item disappear, use Hide followed by Layout .

Use parameter recursive to hide elements found in subsizers. Returns True if the child item was found, False otherwise.

Parameters:
  • window (wx.Window) –
  • recursive (bool) –
Return type:

bool

See also

IsShown , Show



Hide (self, sizer, recursive=False)

Hides the child sizer.

To make a sizer item disappear, use Hide followed by Layout .

Use parameter recursive to hide elements found in subsizers. Returns True if the child item was found, False otherwise.

Parameters:
  • sizer (wx.Sizer) –
  • recursive (bool) –
Return type:

bool

See also

IsShown , Show



Hide (self, index)

Hides the item at position index.

To make a sizer item disappear, use Hide followed by Layout .

Use parameter recursive to hide elements found in subsizers. Returns True if the child item was found, False otherwise.

Parameters:index (int) –
Return type:bool

See also

IsShown , Show





InformFirstDirection(self, direction, size, availableOtherDir)

Inform sizer about the first direction that has been decided (by parent item).

Returns True if it made use of the information (and recalculated min size).

Parameters:
  • direction (int) –
  • size (int) –
  • availableOtherDir (int) –
Return type:

bool



Insert(self, *args, **kw)

overload Overloaded Implementations:



Insert (self, index, window, flags)

Insert a child into the sizer before any existing item at index.

See Add for the meaning of the other parameters.

Parameters:
Return type:

wx.SizerItem



Insert (self, index, window, proportion=0, flag=0, border=0, userData=None)

Insert a child into the sizer before any existing item at index.

See Add for the meaning of the other parameters.

Parameters:
  • index (int) –
  • window (wx.Window) –
  • proportion (int) –
  • flag (int) –
  • border (int) –
  • userData (PyUserData) –
Return type:

wx.SizerItem



Insert (self, index, sizer, flags)

Insert a child into the sizer before any existing item at index.

See Add for the meaning of the other parameters.

Parameters:
Return type:

wx.SizerItem



Insert (self, index, sizer, proportion=0, flag=0, border=0, userData=None)

Insert a child into the sizer before any existing item at index.

See Add for the meaning of the other parameters.

Parameters:
  • index (int) –
  • sizer (wx.Sizer) –
  • proportion (int) –
  • flag (int) –
  • border (int) –
  • userData (PyUserData) –
Return type:

wx.SizerItem



Insert (self, index, width, height, proportion=0, flag=0, border=0, userData=None)

Insert a child into the sizer before any existing item at index.

See Add for the meaning of the other parameters.

Parameters:
  • index (int) –
  • width (int) –
  • height (int) –
  • proportion (int) –
  • flag (int) –
  • border (int) –
  • userData (PyUserData) –
Return type:

wx.SizerItem



Insert (self, index, width, height, flags)

Insert a child into the sizer before any existing item at index.

See Add for the meaning of the other parameters.

Parameters:
  • index (int) –
  • width (int) –
  • height (int) –
  • flags (wx.SizerFlags) –
Return type:

wx.SizerItem



Insert (self, index, item)

Parameters:
Return type:

wx.SizerItem



Insert (self, index, size, proportion=0, flag=0, border=0, /Transfer/=None)

Insert a spacer using a Size object.

Return type: wx.SizerItem



Insert (self, index, size, flags)

Insert a spacer using a Size object.

Return type: wx.SizerItem





InsertSpacer(self, index, size)

Inserts non-stretchable space to the sizer.

More readable way of calling Sizer.Insert(index, size, size).

Parameters:
  • index (int) –
  • size (int) –
Return type:

wx.SizerItem



InsertStretchSpacer(self, index, prop=1)

Inserts stretchable space to the sizer.

More readable way of calling Sizer.Insert(0, 0, prop).

Parameters:
  • index (int) –
  • prop (int) –
Return type:

wx.SizerItem



IsEmpty(self)

Return True if the sizer has no elements.

Return type:bool

See also

GetItemCount



IsShown(self, *args, **kw)

overload Overloaded Implementations:



IsShown (self, window)

Returns True if the window is shown.

Parameters:window (wx.Window) –
Return type:bool



IsShown (self, sizer)

Returns True if the sizer is shown.

Parameters:sizer (wx.Sizer) –
Return type:bool



IsShown (self, index)

Returns True if the item at index is shown.

Parameters:index (int) –
Return type:bool





Layout(self)

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(self, *args, **kw)

overload Overloaded Implementations:



Prepend (self, window, flags)

Same as Add , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

Parameters:
Return type:

wx.SizerItem



Prepend (self, window, proportion=0, flag=0, border=0, userData=None)

Same as Add , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

Parameters:
  • window (wx.Window) –
  • proportion (int) –
  • flag (int) –
  • border (int) –
  • userData (PyUserData) –
Return type:

wx.SizerItem



Prepend (self, sizer, flags)

Same as Add , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

Parameters:
Return type:

wx.SizerItem



Prepend (self, sizer, proportion=0, flag=0, border=0, userData=None)

Same as Add , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

Parameters:
  • sizer (wx.Sizer) –
  • proportion (int) –
  • flag (int) –
  • border (int) –
  • userData (PyUserData) –
Return type:

wx.SizerItem



Prepend (self, width, height, proportion=0, flag=0, border=0, userData=None)

Same as Add , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

Parameters:
  • width (int) –
  • height (int) –
  • proportion (int) –
  • flag (int) –
  • border (int) –
  • userData (PyUserData) –
Return type:

wx.SizerItem



Prepend (self, width, height, flags)

Same as Add , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer.

Parameters:
Return type:

wx.SizerItem



Prepend (self, item)

Parameters:item (wx.SizerItem) –
Return type: wx.SizerItem



Prepend (self, size, proportion=0, flag=0, border=0, /Transfer/=None)

Prepend a spacer using a Size object.

Return type: wx.SizerItem



Prepend (self, size, flags)

Prepend a spacer using a Size object.

Return type: wx.SizerItem





PrependSpacer(self, size)

Prepends non-stretchable space to the sizer.

More readable way of calling Sizer.Prepend(size, size, 0).

Parameters:size (int) –
Return type: wx.SizerItem


PrependStretchSpacer(self, prop=1)

Prepends stretchable space to the sizer.

More readable way of calling Sizer.Prepend(0, 0, prop).

Parameters:prop (int) –
Return type: wx.SizerItem


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.



Remove(self, *args, **kw)

overload Overloaded Implementations:



Remove (self, sizer)

Removes a sizer child from the sizer and destroys it.

Parameters:sizer (wx.Sizer) – The wx.Sizer to be removed.
Return type:bool
Returns:True if the child item was found and removed, False otherwise.

Note

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



Remove (self, index)

Removes a child from the sizer and destroys it if it is a sizer or a spacer, but not if it is a window (because windows are owned by their parent window, not the sizer).

Parameters:index (int) – The position of the child in the sizer, e.g. 0 for the first item.
Return type:bool
Returns:True if the child item was found and removed, False otherwise.

Note

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





Replace(self, *args, **kw)

overload Overloaded Implementations:



Replace (self, oldwin, newwin, recursive=False)

Detaches the given oldwin from the sizer and replaces it with the given newwin.

The detached child window is not deleted (because windows are owned by their parent window, not the sizer).

Use parameter recursive to search the given element recursively in subsizers.

This method does not cause any layout or resizing to take place, call Layout to update the layout “on screen” after replacing a child from the sizer.

Returns True if the child item was found and removed, False otherwise.

Parameters:
Return type:

bool



Replace (self, oldsz, newsz, recursive=False)

Detaches the given oldsz from the sizer and replaces it with the given newsz.

The detached child sizer is deleted.

Use parameter recursive to search the given element recursively in subsizers.

This method does not cause any layout or resizing to take place, call Layout to update the layout “on screen” after replacing a child from the sizer.

Returns True if the child item was found and removed, False otherwise.

Parameters:
Return type:

bool



Replace (self, index, newitem)

Detaches the given item at position index from the sizer and replaces it with the given wx.SizerItem newitem.

The detached child is deleted only if it is a sizer or a spacer (but not if it is a wx.Window because windows are owned by their parent window, not the sizer).

This method does not cause any layout or resizing to take place, call Layout to update the layout “on screen” after replacing a child from the sizer.

Returns True if the child item was found and removed, False otherwise.

Parameters:
Return type:

bool





SetContainingWindow(self, window)

Set the window this sizer is used in.

Parameters:window (wx.Window) –


SetDimension(self, *args, **kw)

overload Overloaded Implementations:



SetDimension (self, x, y, width, height)

Call this to force the sizer to take the given dimension and thus force the items owned by the sizer to resize themselves according to the rules defined by the parameter in the Add and Prepend methods.

Parameters:
  • x (int) –
  • y (int) –
  • width (int) –
  • height (int) –



SetDimension (self, pos, size)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:





SetItemMinSize(self, *args, **kw)

Set an item’s minimum size by window, sizer, or position.

This function enables an application to set the size of an item after initial creation.

The window or sizer will be found recursively in the sizer’s descendants.

Returns:True if the minimal size was successfully set or False if the item was not found.

overload Overloaded Implementations:



SetItemMinSize (self, window, width, height)

Parameters:
  • window (wx.Window) –
  • width (int) –
  • height (int) –
Return type:

bool



SetItemMinSize (self, window, size)

Parameters:
Return type:

bool



SetItemMinSize (self, sizer, width, height)

Parameters:
  • sizer (wx.Sizer) –
  • width (int) –
  • height (int) –
Return type:

bool



SetItemMinSize (self, sizer, size)

Parameters:
Return type:

bool



SetItemMinSize (self, index, width, height)

Parameters:
  • index (int) –
  • width (int) –
  • height (int) –
Return type:

bool



SetItemMinSize (self, index, size)

Parameters:
  • index (int) –
  • size (wx.Size) –
Return type:

bool





SetMinSize(self, *args, **kw)

overload Overloaded Implementations:



SetMinSize (self, size)

Call this to give the sizer a minimal size.

Normally, the sizer will calculate its minimal size based purely on how much space its children need. After calling this method GetMinSize will return either the minimal size as requested by its children or the minimal size set here, depending on which is bigger.

Parameters:size (wx.Size) –



SetMinSize (self, width, height)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
  • width (int) –
  • height (int) –





SetSizeHints(self, window)

This method first calls Fit and then wx.TopLevelWindow.SetSizeHints on the window passed to it.

This only makes sense when window is actually a wx.TopLevelWindow such as a wx.Frame or a wx.Dialog, since SetSizeHints only has any effect in these classes. It does nothing in normal windows or controls.

This method is implicitly used by wx.Window.SetSizerAndFit which is commonly invoked in the constructor of a toplevel window itself (see the sample in the description of wx.BoxSizer) if the toplevel window is resizable.

Parameters:window (wx.Window) –


SetVirtualSizeHints(self, window)

Tell the sizer to set the minimal size of the window virtual area to match the sizer’s minimal size.

For windows with managed scrollbars this will set them appropriately.

Parameters:window (wx.Window) –

Deprecated since version 4.0.0: This is exactly the same as FitInside in wxWidgets 2.9 and later, please replace calls to it with FitInside .



Show(self, *args, **kw)

overload Overloaded Implementations:



Show (self, window, show=True, recursive=False)

Shows or hides the window.

To make a sizer item disappear or reappear, use Show followed by Layout .

Use parameter recursive to show or hide elements found in subsizers.

Returns True if the child item was found, False otherwise.

Parameters:
  • window (wx.Window) –
  • show (bool) –
  • recursive (bool) –
Return type:

bool

See also

Hide , IsShown



Show (self, sizer, show=True, recursive=False)

Shows or hides sizer.

To make a sizer item disappear or reappear, use Show followed by Layout .

Use parameter recursive to show or hide elements found in subsizers.

Returns True if the child item was found, False otherwise.

Parameters:
  • sizer (wx.Sizer) –
  • show (bool) –
  • recursive (bool) –
Return type:

bool

See also

Hide , IsShown



Show (self, index, show=True)

Shows the item at index.

To make a sizer item disappear or reappear, use Show followed by Layout .

Returns True if the child item was found, False otherwise.

Parameters:
  • index (int) –
  • show (bool) –
Return type:

bool

See also

Hide , IsShown





ShowItems(self, show)

Show or hide all items managed by the sizer.

Parameters:show (bool) –


__nonzero__(self)

Can be used to test if the C++ part of the sizer still exists, with code like this:

if theSizer:
        doSomething()

Properties



Children

See GetChildren



ContainingWindow

See GetContainingWindow and SetContainingWindow



ItemCount

See GetItemCount



MinSize

See GetMinSize and SetMinSize



Position

See GetPosition



Size

See GetSize