.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. _wx.Sizer: ========================================================================================================================================== |phoenix_title| **wx.Sizer** ========================================================================================================================================== :ref:`wx.Sizer` is the abstract base class used for laying out subwindows in a window. You cannot use :ref:`wx.Sizer` directly; instead, you will have to use one of the sizer classes derived from it. Currently there are :ref:`wx.BoxSizer`, :ref:`wx.StaticBoxSizer`, :ref:`wx.GridSizer`, :ref:`wx.FlexGridSizer`, :ref:`wx.WrapSizer` and :ref:`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 :ref:`wx.Sizer` does not derive from :ref:`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 :meth:`wx.Sizer.Add` , :meth:`wx.Sizer.Insert` , and :meth:`wx.Sizer.Prepend` functions return a pointer to the newly added :ref:`wx.SizerItem`. Just add empty space of the desired size and attributes, and then use the :meth:`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 :ref:`wx.SizerItem` constructors and other functions, e.g. :meth:`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. .. include:: rest_substitutions\tables\wx.Sizer.1.rst .. seealso:: :ref:`Sizers Overview ` | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class Sizer:
| |sub_classes| Known Subclasses ============================== :ref:`wx.BoxSizer`, :ref:`wx.GridSizer` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.Sizer.__init__` The constructor. :meth:`~wx.Sizer.Add` Appends a child to the sizer. :meth:`~wx.Sizer.AddMany` :meth:`~Sizer.AddMany` is a convenience method for adding several items to a sizer :meth:`~wx.Sizer.AddSpacer` This base function adds non-stretchable space to both the horizontal and vertical orientation of the sizer. :meth:`~wx.Sizer.AddStretchSpacer` Adds stretchable space to the sizer. :meth:`~wx.Sizer.CalcMin` This method is abstract and has to be overwritten by any derived class. :meth:`~wx.Sizer.Clear` Detaches all children from the sizer. :meth:`~wx.Sizer.ComputeFittingClientSize` Computes client area size for `window` so that it matches the sizer's minimal size. :meth:`~wx.Sizer.ComputeFittingWindowSize` Like :meth:`~Sizer.ComputeFittingClientSize` , but converts the result into window size. :meth:`~wx.Sizer.Detach` Detach the child `window` from the sizer without destroying it. :meth:`~wx.Sizer.Fit` Tell the sizer to resize the `window` so that its client area matches the sizer's minimal size ( :meth:`~Sizer.ComputeFittingClientSize` is called to determine it). :meth:`~wx.Sizer.FitInside` Tell the sizer to resize the virtual size of the `window` to match the sizer's minimal size. :meth:`~wx.Sizer.GetChildren` Returns the list of the items in this sizer. :meth:`~wx.Sizer.GetContainingWindow` Returns the window this sizer is used in or ``None`` if none. :meth:`~wx.Sizer.GetItem` Finds the :ref:`wx.SizerItem` which holds the given `window`. :meth:`~wx.Sizer.GetItemById` Finds the item in the sizer which has the given `id`. :meth:`~wx.Sizer.GetItemCount` Returns the number of items in the sizer. :meth:`~wx.Sizer.GetMinSize` Returns the minimal size of the sizer. :meth:`~wx.Sizer.GetPosition` Returns the current position of the sizer. :meth:`~wx.Sizer.GetSize` Returns the current size of the sizer. :meth:`~wx.Sizer.Hide` Hides the child `window`. :meth:`~wx.Sizer.InformFirstDirection` Inform sizer about the first direction that has been decided (by parent item). :meth:`~wx.Sizer.Insert` Insert a child into the sizer before any existing item at `index`. :meth:`~wx.Sizer.InsertSpacer` Inserts non-stretchable space to the sizer. :meth:`~wx.Sizer.InsertStretchSpacer` Inserts stretchable space to the sizer. :meth:`~wx.Sizer.IsEmpty` Return ``True`` if the sizer has no elements. :meth:`~wx.Sizer.IsShown` Returns ``True`` if the `window` is shown. :meth:`~wx.Sizer.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. :meth:`~wx.Sizer.Prepend` Same as :meth:`~Sizer.Add` , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer. :meth:`~wx.Sizer.PrependSpacer` Prepends non-stretchable space to the sizer. :meth:`~wx.Sizer.PrependStretchSpacer` Prepends stretchable space to the sizer. :meth:`~wx.Sizer.RecalcSizes` This is a deprecated version of RepositionChildren() :meth:`~wx.Sizer.Remove` Removes a sizer child from the sizer and destroys it. :meth:`~wx.Sizer.Replace` Detaches the given `oldwin` from the sizer and replaces it with the given `newwin`. :meth:`~wx.Sizer.RepositionChildren` Method which must be overridden in the derived sizer classes. :meth:`~wx.Sizer.SetContainingWindow` Set the window this sizer is used in. :meth:`~wx.Sizer.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 :meth:`~Sizer.Add` and :meth:`~Sizer.Prepend` methods. :meth:`~wx.Sizer.SetItemMinSize` Set an item's minimum size by window, sizer, or position. :meth:`~wx.Sizer.SetMinSize` Call this to give the sizer a minimal size. :meth:`~wx.Sizer.SetSizeHints` This method first calls :meth:`~Sizer.Fit` and then :meth:`wx.TopLevelWindow.SetSizeHints` on the `window` passed to it. :meth:`~wx.Sizer.Show` Shows or hides the `window`. :meth:`~wx.Sizer.ShowItems` Show or hide all items managed by the sizer. :meth:`~wx.Sizer.__iter__` A Python convenience method that allows Sizers to act as iterables that will yield their wx.SizerItems. :meth:`~wx.Sizer.__nonzero__` Can be used to test if the C++ part of the sizer still exists, with ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~wx.Sizer.Children` See :meth:`~wx.Sizer.GetChildren` :attr:`~wx.Sizer.ContainingWindow` See :meth:`~wx.Sizer.GetContainingWindow` and :meth:`~wx.Sizer.SetContainingWindow` :attr:`~wx.Sizer.ItemCount` See :meth:`~wx.Sizer.GetItemCount` :attr:`~wx.Sizer.MinSize` See :meth:`~wx.Sizer.GetMinSize` and :meth:`~wx.Sizer.SetMinSize` :attr:`~wx.Sizer.Position` See :meth:`~wx.Sizer.GetPosition` :attr:`~wx.Sizer.Size` See :meth:`~wx.Sizer.GetSize` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.Sizer(Object) **Possible constructors**:: Sizer() Sizer is the abstract base class used for laying out subwindows in a window. .. method:: __init__(self) The constructor. Note that :ref:`wx.Sizer` is an abstract base class and may not be instantiated. .. method:: Add(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **Add** `(self, window, flags)` Appends a child to the sizer. :ref:`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: :param `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. :type `window`: wx.Window :param `flags`: A :ref:`wx.SizerFlags` object that enables you to specify most of the above parameters more conveniently. :type `flags`: wx.SizerFlags :rtype: :ref:`wx.SizerItem` :html:`

` **Add** `(self, window, proportion=0, flag=0, border=0, userData=None)` Appends a child to the sizer. :ref:`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: :param `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. :type `window`: wx.Window :param `proportion`: Although the meaning of this parameter is undefined in :ref:`wx.Sizer`, it is used in :ref:`wx.BoxSizer` to indicate if a child of a sizer can change its size in the main orientation of the :ref:`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 :ref:`wx.BoxSizer`. For example, you might have a horizontal :ref:`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. :type `proportion`: int :param `flag`: OR-combination of flags affecting sizer's behaviour. See :ref:`Sizer flags list ` for details. :type `flag`: int :param `border`: Determines the border width, if the flag parameter is set to include any border flag. :type `border`: int :param `userData`: 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. :type `userData`: PyUserData :rtype: :ref:`wx.SizerItem` :html:`

` **Add** `(self, sizer, flags)` Appends a child to the sizer. :ref:`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: :param `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). :type `sizer`: wx.Sizer :param `flags`: A :ref:`wx.SizerFlags` object that enables you to specify most of the above parameters more conveniently. :type `flags`: wx.SizerFlags :rtype: :ref:`wx.SizerItem` :html:`

` **Add** `(self, sizer, proportion=0, flag=0, border=0, userData=None)` Appends a child to the sizer. :ref:`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: :param `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). :type `sizer`: wx.Sizer :param `proportion`: Although the meaning of this parameter is undefined in :ref:`wx.Sizer`, it is used in :ref:`wx.BoxSizer` to indicate if a child of a sizer can change its size in the main orientation of the :ref:`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 :ref:`wx.BoxSizer`. For example, you might have a horizontal :ref:`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. :type `proportion`: int :param `flag`: OR-combination of flags affecting sizer's behaviour. See :ref:`Sizer flags list ` for details. :type `flag`: int :param `border`: Determines the border width, if the flag parameter is set to include any border flag. :type `border`: int :param `userData`: 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. :type `userData`: PyUserData :rtype: :ref:`wx.SizerItem` :html:`

` **Add** `(self, width, height, proportion=0, flag=0, border=0, userData=None)` Appends a spacer child to the sizer. :ref:`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. :param `width`: Width of the spacer. :type `width`: int :param `height`: Height of the spacer. :type `height`: int :param `proportion`: Although the meaning of this parameter is undefined in :ref:`wx.Sizer`, it is used in :ref:`wx.BoxSizer` to indicate if a child of a sizer can change its size in the main orientation of the :ref:`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 :ref:`wx.BoxSizer`. For example, you might have a horizontal :ref:`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. :type `proportion`: int :param `flag`: OR-combination of flags affecting sizer's behaviour. See :ref:`Sizer flags list ` for details. :type `flag`: int :param `border`: Determines the border width, if the flag parameter is set to include any border flag. :type `border`: int :param `userData`: 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. :type `userData`: PyUserData :rtype: :ref:`wx.SizerItem` :html:`

` **Add** `(self, width, height, flags)` Appends a spacer child to the sizer. :param `width`: Width of the spacer. :type `width`: int :param `height`: Height of the spacer. :type `height`: int :param `flags`: A :ref:`wx.SizerFlags` object that enables you to specify most of the other parameters more conveniently. :type `flags`: wx.SizerFlags :rtype: :ref:`wx.SizerItem` :html:`

` **Add** `(self, item)` :param `item`: :type `item`: wx.SizerItem :rtype: :ref:`wx.SizerItem` :html:`

` **Add** `(self, size, proportion=0, flag=0, border=0, /Transfer/=None)` Add a spacer using a :class:`Size` object. :rtype: :ref:`wx.SizerItem` :html:`

` **Add** `(self, size, flags)` Add a spacer using a :class:`Size` object. :rtype: :ref:`wx.SizerItem` :html:`

` .. method:: AddMany(self, items) :meth:`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 :meth:`Add` method. .. 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) :param `size`: :type `size`: int :rtype: :ref:`wx.SizerItem` .. seealso:: :meth:`wx.BoxSizer.AddSpacer` .. method:: AddStretchSpacer(self, prop=1) Adds stretchable space to the sizer. More readable way of calling: :: wx.Sizer.Add(0, 0, proportion) :param `prop`: :type `prop`: int :rtype: :ref:`wx.SizerItem` .. method:: 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. :rtype: :ref:`wx.Size` .. method:: 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). :param `delete_windows`: :type `delete_windows`: bool .. method:: ComputeFittingClientSize(self, window) Computes client area size for `window` so that it matches the sizer's minimal size. Unlike :meth:`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 :meth:`wx.Window.SetMaxSize` . The returned value is suitable for passing to :meth:`wx.Window.SetClientSize` or :meth:`wx.Window.SetMinClientSize` . :param `window`: :type `window`: wx.Window :rtype: :ref:`wx.Size` .. versionadded:: 2.8.8 .. seealso:: :meth:`ComputeFittingWindowSize` , :meth:`Fit` .. method:: ComputeFittingWindowSize(self, window) Like :meth:`ComputeFittingClientSize` , but converts the result into window size. The returned value is suitable for passing to :meth:`wx.Window.SetSize` or :meth:`wx.Window.SetMinSize` . :param `window`: :type `window`: wx.Window :rtype: :ref:`wx.Size` .. versionadded:: 2.8.8 .. seealso:: :meth:`ComputeFittingClientSize` , :meth:`Fit` .. method:: Detach(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **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 :meth:`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. :param `window`: :type `window`: wx.Window :rtype: `bool` .. seealso:: :meth:`Remove` :html:`

` **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 :meth:`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. :param `sizer`: :type `sizer`: wx.Sizer :rtype: `bool` .. seealso:: :meth:`Remove` :html:`

` **Detach** `(self, index)` Detach an item at position `index` from the sizer without destroying it. This method does not cause any layout or resizing to take place, call :meth:`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. :param `index`: :type `index`: int :rtype: `bool` .. seealso:: :meth:`Remove` :html:`

` .. method:: Fit(self, window) Tell the sizer to resize the `window` so that its client area matches the sizer's minimal size ( :meth:`ComputeFittingClientSize` is called to determine it). This is commonly done in the constructor of the window itself, see sample in the description of :ref:`wx.BoxSizer`. :param `window`: :type `window`: wx.Window :rtype: :ref:`wx.Size` :returns: The new window size. .. seealso:: :meth:`ComputeFittingClientSize` , :meth:`ComputeFittingWindowSize` .. method:: 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. :param `window`: :type `window`: wx.Window .. seealso:: :meth:`wx.Scrolled.SetScrollbars` , :meth:`SetVirtualSizeHints` .. method:: GetChildren(self) Returns the list of the items in this sizer. The elements of type-safe List ``SizerItemList`` are pointers to objects of type :ref:`wx.SizerItem`. :rtype: `SizerItemList` .. method:: GetContainingWindow(self) Returns the window this sizer is used in or ``None`` if none. :rtype: :ref:`wx.Window` .. method:: GetItem(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **GetItem** `(self, window, recursive=False)` Finds the :ref:`wx.SizerItem` which holds the given `window`. Use parameter `recursive` to search in subsizers too. :param `window`: :type `window`: wx.Window :param `recursive`: :type `recursive`: bool :rtype: :ref:`wx.SizerItem` :returns: Pointer to the item or ``None`` if there is no item with the window. :html:`

` **GetItem** `(self, sizer, recursive=False)` Finds the :ref:`wx.SizerItem` which holds the given `sizer`. Use parameter `recursive` to search in subsizers too. :param `sizer`: :type `sizer`: wx.Sizer :param `recursive`: :type `recursive`: bool :rtype: :ref:`wx.SizerItem` :returns: Pointer to the item or ``None`` if the given sizer is not in the sizer. :html:`

` **GetItem** `(self, index)` Finds the :ref:`wx.SizerItem` which is located in the sizer at position `index`. :param `index`: :type `index`: int :rtype: :ref:`wx.SizerItem` :returns: Pointer to the item or ``None`` if there is no item at that index. :html:`

` .. method:: GetItemById(self, id, recursive=False) Finds the item in the sizer which has the given `id`. This `id` is not the window id but the id of the :ref:`wx.SizerItem` itself. This is mainly useful for retrieving the sizers created from ``XRC`` resources. Use parameter `recursive` to search in subsizers too. :param `id`: :type `id`: int :param `recursive`: :type `recursive`: bool :rtype: :ref:`wx.SizerItem` :returns: Pointer to item or ``None`` if no item has that id. .. method:: 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 the :meth:`IsEmpty` function. :rtype: `int` .. method:: 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 :meth:`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 :meth:`wx.Window.SetMinClientSize` or :meth:`wx.Window.SetClientSize` , not :meth:`wx.Window.SetMinSize` or :meth:`wx.Window.SetSize` . :rtype: :ref:`wx.Size` .. method:: GetPosition(self) Returns the current position of the sizer. :rtype: :ref:`wx.Point` .. method:: GetSize(self) Returns the current size of the sizer. :rtype: :ref:`wx.Size` .. method:: Hide(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **Hide** `(self, window, recursive=False)` Hides the child `window`. To make a sizer item disappear, use :meth:`Hide` followed by :meth:`Layout` . Use parameter `recursive` to hide elements found in subsizers. Returns ``True`` if the child item was found, ``False`` otherwise. :param `window`: :type `window`: wx.Window :param `recursive`: :type `recursive`: bool :rtype: `bool` .. seealso:: :meth:`IsShown` , :meth:`Show` :html:`

` **Hide** `(self, sizer, recursive=False)` Hides the child `sizer`. To make a sizer item disappear, use :meth:`Hide` followed by :meth:`Layout` . Use parameter `recursive` to hide elements found in subsizers. Returns ``True`` if the child item was found, ``False`` otherwise. :param `sizer`: :type `sizer`: wx.Sizer :param `recursive`: :type `recursive`: bool :rtype: `bool` .. seealso:: :meth:`IsShown` , :meth:`Show` :html:`

` **Hide** `(self, index)` Hides the item at position `index`. To make a sizer item disappear, use :meth:`Hide` followed by :meth:`Layout` . Use parameter `recursive` to hide elements found in subsizers. Returns ``True`` if the child item was found, ``False`` otherwise. :param `index`: :type `index`: int :rtype: `bool` .. seealso:: :meth:`IsShown` , :meth:`Show` :html:`

` .. method:: 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). :param `direction`: :type `direction`: int :param `size`: :type `size`: int :param `availableOtherDir`: :type `availableOtherDir`: int :rtype: `bool` .. method:: Insert(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **Insert** `(self, index, window, flags)` Insert a child into the sizer before any existing item at `index`. See :meth:`Add` for the meaning of the other parameters. :param `index`: :type `index`: int :param `window`: :type `window`: wx.Window :param `flags`: :type `flags`: wx.SizerFlags :rtype: :ref:`wx.SizerItem` :html:`

` **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 :meth:`Add` for the meaning of the other parameters. :param `index`: :type `index`: int :param `window`: :type `window`: wx.Window :param `proportion`: :type `proportion`: int :param `flag`: :type `flag`: int :param `border`: :type `border`: int :param `userData`: :type `userData`: PyUserData :rtype: :ref:`wx.SizerItem` :html:`

` **Insert** `(self, index, sizer, flags)` Insert a child into the sizer before any existing item at `index`. See :meth:`Add` for the meaning of the other parameters. :param `index`: :type `index`: int :param `sizer`: :type `sizer`: wx.Sizer :param `flags`: :type `flags`: wx.SizerFlags :rtype: :ref:`wx.SizerItem` :html:`

` **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 :meth:`Add` for the meaning of the other parameters. :param `index`: :type `index`: int :param `sizer`: :type `sizer`: wx.Sizer :param `proportion`: :type `proportion`: int :param `flag`: :type `flag`: int :param `border`: :type `border`: int :param `userData`: :type `userData`: PyUserData :rtype: :ref:`wx.SizerItem` :html:`

` **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 :meth:`Add` for the meaning of the other parameters. :param `index`: :type `index`: int :param `width`: :type `width`: int :param `height`: :type `height`: int :param `proportion`: :type `proportion`: int :param `flag`: :type `flag`: int :param `border`: :type `border`: int :param `userData`: :type `userData`: PyUserData :rtype: :ref:`wx.SizerItem` :html:`

` **Insert** `(self, index, width, height, flags)` Insert a child into the sizer before any existing item at `index`. See :meth:`Add` for the meaning of the other parameters. :param `index`: :type `index`: int :param `width`: :type `width`: int :param `height`: :type `height`: int :param `flags`: :type `flags`: wx.SizerFlags :rtype: :ref:`wx.SizerItem` :html:`

` **Insert** `(self, index, item)` :param `index`: :type `index`: int :param `item`: :type `item`: wx.SizerItem :rtype: :ref:`wx.SizerItem` :html:`

` **Insert** `(self, index, size, proportion=0, flag=0, border=0, /Transfer/=None)` Insert a spacer using a :class:`Size` object. :rtype: :ref:`wx.SizerItem` :html:`

` **Insert** `(self, index, size, flags)` Insert a spacer using a :class:`Size` object. :rtype: :ref:`wx.SizerItem` :html:`

` .. method:: InsertSpacer(self, index, size) Inserts non-stretchable space to the sizer. More readable way of calling `Sizer.Insert(index,` size, size). :param `index`: :type `index`: int :param `size`: :type `size`: int :rtype: :ref:`wx.SizerItem` .. method:: InsertStretchSpacer(self, index, prop=1) Inserts stretchable space to the sizer. More readable way of calling `Sizer.Insert(0,` 0, prop). :param `index`: :type `index`: int :param `prop`: :type `prop`: int :rtype: :ref:`wx.SizerItem` .. method:: IsEmpty(self) Return ``True`` if the sizer has no elements. :rtype: `bool` .. seealso:: :meth:`GetItemCount` .. method:: IsShown(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **IsShown** `(self, window)` Returns ``True`` if the `window` is shown. :param `window`: :type `window`: wx.Window :rtype: `bool` .. seealso:: :meth:`Hide` , :meth:`Show` , :meth:`wx.SizerItem.IsShown` :html:`

` **IsShown** `(self, sizer)` Returns ``True`` if the `sizer` is shown. :param `sizer`: :type `sizer`: wx.Sizer :rtype: `bool` .. seealso:: :meth:`Hide` , :meth:`Show` , :meth:`wx.SizerItem.IsShown` :html:`

` **IsShown** `(self, index)` Returns ``True`` if the item at `index` is shown. :param `index`: :type `index`: int :rtype: `bool` .. seealso:: :meth:`Hide` , :meth:`Show` , :meth:`wx.SizerItem.IsShown` :html:`

` .. method:: 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. .. method:: Prepend(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **Prepend** `(self, window, flags)` Same as :meth:`Add` , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer. :param `window`: :type `window`: wx.Window :param `flags`: :type `flags`: wx.SizerFlags :rtype: :ref:`wx.SizerItem` :html:`

` **Prepend** `(self, window, proportion=0, flag=0, border=0, userData=None)` Same as :meth:`Add` , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer. :param `window`: :type `window`: wx.Window :param `proportion`: :type `proportion`: int :param `flag`: :type `flag`: int :param `border`: :type `border`: int :param `userData`: :type `userData`: PyUserData :rtype: :ref:`wx.SizerItem` :html:`

` **Prepend** `(self, sizer, flags)` Same as :meth:`Add` , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer. :param `sizer`: :type `sizer`: wx.Sizer :param `flags`: :type `flags`: wx.SizerFlags :rtype: :ref:`wx.SizerItem` :html:`

` **Prepend** `(self, sizer, proportion=0, flag=0, border=0, userData=None)` Same as :meth:`Add` , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer. :param `sizer`: :type `sizer`: wx.Sizer :param `proportion`: :type `proportion`: int :param `flag`: :type `flag`: int :param `border`: :type `border`: int :param `userData`: :type `userData`: PyUserData :rtype: :ref:`wx.SizerItem` :html:`

` **Prepend** `(self, width, height, proportion=0, flag=0, border=0, userData=None)` Same as :meth:`Add` , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer. :param `width`: :type `width`: int :param `height`: :type `height`: int :param `proportion`: :type `proportion`: int :param `flag`: :type `flag`: int :param `border`: :type `border`: int :param `userData`: :type `userData`: PyUserData :rtype: :ref:`wx.SizerItem` :html:`

` **Prepend** `(self, width, height, flags)` Same as :meth:`Add` , but prepends the items to the beginning of the list of items (windows, subsizers or spaces) owned by this sizer. :param `width`: :type `width`: int :param `height`: :type `height`: int :param `flags`: :type `flags`: wx.SizerFlags :rtype: :ref:`wx.SizerItem` :html:`

` **Prepend** `(self, item)` :param `item`: :type `item`: wx.SizerItem :rtype: :ref:`wx.SizerItem` :html:`

` **Prepend** `(self, size, proportion=0, flag=0, border=0, /Transfer/=None)` Prepend a spacer using a :class:`Size` object. :rtype: :ref:`wx.SizerItem` :html:`

` **Prepend** `(self, size, flags)` Prepend a spacer using a :class:`Size` object. :rtype: :ref:`wx.SizerItem` :html:`

` .. method:: PrependSpacer(self, size) Prepends non-stretchable space to the sizer. More readable way of calling `Sizer.Prepend(size,` size, 0). :param `size`: :type `size`: int :rtype: :ref:`wx.SizerItem` .. method:: PrependStretchSpacer(self, prop=1) Prepends stretchable space to the sizer. More readable way of calling `Sizer.Prepend(0,` 0, prop). :param `prop`: :type `prop`: int :rtype: :ref:`wx.SizerItem` .. method:: RecalcSizes(self) This is a deprecated version of RepositionChildren() This is a deprecated version of RepositionChildren() which doesn't take the minimal size parameter which is not needed for very simple sizers but typically is for anything more complicated, so prefer to override RepositionChildren() in new code. If RepositionChildren() is not overridden, this method must be overridden, calling the base class version results in an assertion failure. .. method:: Remove(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **Remove** `(self, sizer)` Removes a sizer child from the sizer and destroys it. :param `sizer`: The :ref:`wx.Sizer` to be removed. :type `sizer`: wx.Sizer :rtype: `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 :meth:`Layout` to update the layout "on screen" after removing a child from the sizer. :html:`

` **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). :param `index`: The position of the child in the sizer, e.g. 0 for the first item. :type `index`: int :rtype: `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 :meth:`Layout` to update the layout "on screen" after removing a child from the sizer. :html:`

` .. method:: Replace(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **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 :meth:`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. :param `oldwin`: :type `oldwin`: wx.Window :param `newwin`: :type `newwin`: wx.Window :param `recursive`: :type `recursive`: bool :rtype: `bool` :html:`

` **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 :meth:`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. :param `oldsz`: :type `oldsz`: wx.Sizer :param `newsz`: :type `newsz`: wx.Sizer :param `recursive`: :type `recursive`: bool :rtype: `bool` :html:`

` **Replace** `(self, index, newitem)` Detaches the given item at position `index` from the sizer and replaces it with the given :ref:`wx.SizerItem` `newitem`. The detached child is deleted **only** if it is a sizer or a spacer (but not if it is a :ref:`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 :meth:`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. :param `index`: :type `index`: int :param `newitem`: :type `newitem`: wx.SizerItem :rtype: `bool` :html:`

` .. method:: RepositionChildren(self, minSize) Method which must be overridden in the derived sizer classes. The implementation should reposition the children using the current total size available to the sizer ( ``m_size`` ) and the size computed by the last call to :meth:`CalcMin` . Note that you should never call this method directly, call :meth:`Layout` instead if you need to manually update the sizer elements positions. This method is only called by wxWidgets itself. :param `minSize`: :type `minSize`: wx.Size .. versionadded:: 4.1/wxWidgets-3.1.3 , before this version RecalcSizes() method not taking any arguments had to be overridden in the derived classes instead. .. method:: SetContainingWindow(self, window) Set the window this sizer is used in. :param `window`: :type `window`: wx.Window .. method:: SetDimension(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **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 :meth:`Add` and :meth:`Prepend` methods. :param `x`: :type `x`: int :param `y`: :type `y`: int :param `width`: :type `width`: int :param `height`: :type `height`: int :html:`

` **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. :param `pos`: :type `pos`: wx.Point :param `size`: :type `size`: wx.Size :html:`

` .. method:: 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. .. seealso:: :meth:`wx.SizerItem.SetMinSize` |overload| Overloaded Implementations: :html:`

` **SetItemMinSize** `(self, window, width, height)` :param `window`: :type `window`: wx.Window :param `width`: :type `width`: int :param `height`: :type `height`: int :rtype: `bool` :html:`

` **SetItemMinSize** `(self, window, size)` :param `window`: :type `window`: wx.Window :param `size`: :type `size`: wx.Size :rtype: `bool` :html:`

` **SetItemMinSize** `(self, sizer, width, height)` :param `sizer`: :type `sizer`: wx.Sizer :param `width`: :type `width`: int :param `height`: :type `height`: int :rtype: `bool` :html:`

` **SetItemMinSize** `(self, sizer, size)` :param `sizer`: :type `sizer`: wx.Sizer :param `size`: :type `size`: wx.Size :rtype: `bool` :html:`

` **SetItemMinSize** `(self, index, width, height)` :param `index`: :type `index`: int :param `width`: :type `width`: int :param `height`: :type `height`: int :rtype: `bool` :html:`

` **SetItemMinSize** `(self, index, size)` :param `index`: :type `index`: int :param `size`: :type `size`: wx.Size :rtype: `bool` :html:`

` .. method:: SetMinSize(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **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 :meth:`GetMinSize` will return either the minimal size as requested by its children or the minimal size set here, depending on which is bigger. :param `size`: :type `size`: wx.Size :html:`

` **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. :param `width`: :type `width`: int :param `height`: :type `height`: int :html:`

` .. method:: SetSizeHints(self, window) This method first calls :meth:`Fit` and then :meth:`wx.TopLevelWindow.SetSizeHints` on the `window` passed to it. This function is only when `window` is actually a :ref:`wx.TopLevelWindow` such as a :ref:`wx.Frame` or a :ref:`wx.Dialog`, since SetSizeHints only has any effect in these classes. It does nothing in normal windows or controls. Note that `window` does `not` need to be the window using this sizer and it is, in fact, common to call this function on the sizer associated with the panel covering the client area of a frame passing it the frame pointer, as this has the desired effect of adjusting the frame size to the size fitting the panel, e.g.: :: # In a frame's __init__ ... panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(...) sizer.Add(...) panel.SetSizer(sizer) # Use the panel sizer to set the initial and minimal size of the # frame to fit its contents. sizer.SetSizeHints(self) This function is also used by :meth:`wx.Window.SetSizerAndFit` which is commonly invoked in the constructor of Dialog-derived classes, which don't need to use an intermediate panel, see the example in :ref:`BoxSizer overview `. :param `window`: :type `window`: wx.Window .. method:: Show(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **Show** `(self, window, show=True, recursive=False)` Shows or hides the `window`. To make a sizer item disappear or reappear, use :meth:`Show` followed by :meth:`Layout` . Use parameter `recursive` to show or hide elements found in subsizers. Returns ``True`` if the child item was found, ``False`` otherwise. :param `window`: :type `window`: wx.Window :param `show`: :type `show`: bool :param `recursive`: :type `recursive`: bool :rtype: `bool` .. seealso:: :meth:`Hide` , :meth:`IsShown` :html:`

` **Show** `(self, sizer, show=True, recursive=False)` Shows or hides `sizer`. To make a sizer item disappear or reappear, use :meth:`Show` followed by :meth:`Layout` . Use parameter `recursive` to show or hide elements found in subsizers. Returns ``True`` if the child item was found, ``False`` otherwise. :param `sizer`: :type `sizer`: wx.Sizer :param `show`: :type `show`: bool :param `recursive`: :type `recursive`: bool :rtype: `bool` .. seealso:: :meth:`Hide` , :meth:`IsShown` :html:`

` **Show** `(self, index, show=True)` Shows the item at `index`. To make a sizer item disappear or reappear, use :meth:`Show` followed by :meth:`Layout` . Returns ``True`` if the child item was found, ``False`` otherwise. :param `index`: :type `index`: int :param `show`: :type `show`: bool :rtype: `bool` .. seealso:: :meth:`Hide` , :meth:`IsShown` :html:`

` .. method:: ShowItems(self, show) Show or hide all items managed by the sizer. :param `show`: :type `show`: bool .. method:: __iter__(self) A Python convenience method that allows Sizers to act as iterables that will yield their wx.SizerItems. .. method:: __nonzero__(self) Can be used to test if the C++ part of the sizer still exists, with code like this:: if theSizer: doSomething() .. attribute:: Children See :meth:`~wx.Sizer.GetChildren` .. attribute:: ContainingWindow See :meth:`~wx.Sizer.GetContainingWindow` and :meth:`~wx.Sizer.SetContainingWindow` .. attribute:: ItemCount See :meth:`~wx.Sizer.GetItemCount` .. attribute:: MinSize See :meth:`~wx.Sizer.GetMinSize` and :meth:`~wx.Sizer.SetMinSize` .. attribute:: Position See :meth:`~wx.Sizer.GetPosition` .. attribute:: Size See :meth:`~wx.Sizer.GetSize`