.. include:: headings.inc .. _SizerFlags: ========================================================================================================================================== |phoenix_title| **SizerFlags** ========================================================================================================================================== Container for sizer items flags providing readable names for them. Normally, when you add an item to a sizer via :meth:`Sizer.Add` , you have to specify a lot of flags and parameters which can be unwieldy. This is where :ref:`SizerFlags` comes in: it allows you to specify all parameters using the named methods instead. For example, instead of :: sizer.Add(ctrl, 0, wx.EXPAND | wx.ALL, 10) you can now write :: sizer.Add(ctrl, wx.SizerFlags().Expand().Border(wx.ALL, 10)) This is more readable and also allows you to create :ref:`SizerFlags` objects which can be reused for several sizer items. :: flagsExpand = wx.SizerFlags(1) flagsExpand.Expand().Border(wx.ALL, 10) sizer.Add(ctrl1, flagsExpand) sizer.Add(ctrl2, flagsExpand) Note that by specification, all methods of :ref:`SizerFlags` return the :ref:`SizerFlags` object itself to allowing chaining multiple methods calls like in the examples above. .. seealso:: :ref:`Sizer` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **SizerFlags** .. raw:: html

Inheritance diagram of SizerFlags

| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~SizerFlags.__init__` Creates the :ref:`Sizer` with the proportion specified by `proportion`. :meth:`~SizerFlags.Align` Sets the alignment of this :ref:`SizerFlags` to `align`. :meth:`~SizerFlags.Border` Sets the :ref:`SizerFlags` to have a border of a number of pixels specified by `borderinpixels` with the directions specified by `direction`. :meth:`~SizerFlags.Bottom` Aligns the object to the bottom, similar for ``Align(wxALIGN_BOTTOM)`` . :meth:`~SizerFlags.Center` Sets the object of the :ref:`SizerFlags` to center itself in the area it is given. :meth:`~SizerFlags.Centre` :meth:`Center` for people with the other dialect of English. :meth:`~SizerFlags.DoubleBorder` Sets the border in the given `direction` having twice the default border size. :meth:`~SizerFlags.DoubleHorzBorder` Sets the border in left and right directions having twice the default border size. :meth:`~SizerFlags.Expand` Sets the object of the :ref:`SizerFlags` to expand to fill as much area as it can. :meth:`~SizerFlags.FixedMinSize` Set the ``FIXED_MINSIZE`` flag which indicates that the initial size of the window should be also set as its minimal size. :meth:`~SizerFlags.GetDefaultBorder` Returns the border used by default in :ref:`Border` method. :meth:`~SizerFlags.Left` Aligns the object to the left, similar for ``Align(wxALIGN_LEFT)`` . :meth:`~SizerFlags.Proportion` Sets the proportion of this :ref:`SizerFlags` to `proportion`. :meth:`~SizerFlags.ReserveSpaceEvenIfHidden` Set the ``RESERVE_SPACE_EVEN_IF_HIDDEN`` flag. :meth:`~SizerFlags.Right` Aligns the object to the right, similar for ``Align(wxALIGN_RIGHT)`` . :meth:`~SizerFlags.Shaped` Set the ``_SHAPED`` flag which indicates that the elements should always keep the fixed width to height ratio equal to its original value. :meth:`~SizerFlags.Top` Aligns the object to the top, similar for ``Align(wxALIGN_TOP)`` . :meth:`~SizerFlags.TripleBorder` Sets the border in the given `direction` having thrice the default border size. ================================================================================ ================================================================================ | |api| Class API =============== .. class:: SizerFlags(object) Container for sizer items flags providing readable names for them. **Possible constructors**:: SizerFlags(proportion=0) .. method:: __init__(self, proportion=0) Creates the :ref:`Sizer` with the proportion specified by `proportion`. :param `proportion`: :type `proportion`: int .. method:: Align(self, alignment) Sets the alignment of this :ref:`SizerFlags` to `align`. This method replaces the previously set alignment with the specified one. :param `alignment`: Combination of ``ALIGN_XXX`` bit masks. :type `alignment`: int :rtype: :ref:`SizerFlags` .. seealso:: :meth:`Top` , :meth:`Left` , :meth:`Right` , :meth:`Bottom` , :meth:`Centre` .. method:: Border(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **Border** `(self, direction, borderinpixels)` Sets the :ref:`SizerFlags` to have a border of a number of pixels specified by `borderinpixels` with the directions specified by `direction`. :param `direction`: :type `direction`: int :param `borderinpixels`: :type `borderinpixels`: int :rtype: :ref:`SizerFlags` **~~~** **Border** `(self, direction=ALL)` Sets the :ref:`SizerFlags` to have a border with size as returned by :meth:`GetDefaultBorder` . :param `direction`: Direction(s) to apply the border in. :type `direction`: int :rtype: :ref:`SizerFlags` **~~~** .. method:: Bottom(self) Aligns the object to the bottom, similar for ``Align(wxALIGN_BOTTOM)`` . Unlike :meth:`Align` , this method doesn't change the horizontal alignment of the item. :rtype: :ref:`SizerFlags` .. method:: Center(self) Sets the object of the :ref:`SizerFlags` to center itself in the area it is given. :rtype: :ref:`SizerFlags` .. method:: Centre(self) :meth:`Center` for people with the other dialect of English. :rtype: :ref:`SizerFlags` .. method:: DoubleBorder(self, direction=ALL) Sets the border in the given `direction` having twice the default border size. :param `direction`: :type `direction`: int :rtype: :ref:`SizerFlags` .. method:: DoubleHorzBorder(self) Sets the border in left and right directions having twice the default border size. :rtype: :ref:`SizerFlags` .. method:: Expand(self) Sets the object of the :ref:`SizerFlags` to expand to fill as much area as it can. :rtype: :ref:`SizerFlags` .. method:: FixedMinSize(self) Set the ``FIXED_MINSIZE`` flag which indicates that the initial size of the window should be also set as its minimal size. :rtype: :ref:`SizerFlags` .. staticmethod:: GetDefaultBorder() Returns the border used by default in :ref:`Border` method. :rtype: `int` .. method:: Left(self) Aligns the object to the left, similar for ``Align(wxALIGN_LEFT)`` . Unlike :meth:`Align` , this method doesn't change the vertical alignment of the item. :rtype: :ref:`SizerFlags` .. method:: Proportion(self, proportion) Sets the proportion of this :ref:`SizerFlags` to `proportion`. :param `proportion`: :type `proportion`: int :rtype: :ref:`SizerFlags` .. method:: ReserveSpaceEvenIfHidden(self) Set the ``RESERVE_SPACE_EVEN_IF_HIDDEN`` flag. Normally Sizers don't allocate space for hidden windows or other items. This flag overrides this behaviour 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. :rtype: :ref:`SizerFlags` .. versionadded:: 2.8.8 .. method:: Right(self) Aligns the object to the right, similar for ``Align(wxALIGN_RIGHT)`` . Unlike :meth:`Align` , this method doesn't change the vertical alignment of the item. :rtype: :ref:`SizerFlags` .. method:: Shaped(self) Set the ``_SHAPED`` flag which indicates that the elements should always keep the fixed width to height ratio equal to its original value. :rtype: :ref:`SizerFlags` .. method:: Top(self) Aligns the object to the top, similar for ``Align(wxALIGN_TOP)`` . Unlike :meth:`Align` , this method doesn't change the horizontal alignment of the item. :rtype: :ref:`SizerFlags` .. method:: TripleBorder(self, direction=ALL) Sets the border in the given `direction` having thrice the default border size. :param `direction`: :type `direction`: int :rtype: :ref:`SizerFlags`