997
1002
# no support for user data if it's a pseudocontrol
998
1003
# since that is already used
999
1004
def Add(self, item, proportion=0, flag=0, border=0, userData=None):
1000
""" Appends a child item to the sizer. """
1006
Appends a child item to the sizer.
1008
:param `item`: the item to be added to L{BoxSizer}. Can be an instance of `wx.Window`,
1009
`wx.Sizer` or a spacer;
1010
:param `proportion`: this parameter is used in L{BoxSizer} to indicate if a child of
1011
a sizer can change its size in the main orientation of the L{BoxSizer} - where 0
1012
stands for not changeable and a value of more than zero is interpreted relative
1013
to the value of other children of the same L{BoxSizer}. For example, you might have
1014
a horizontal L{BoxSizer} with three children, two of which are supposed to change their
1015
size with the sizer. Then the two stretchable windows would get a value of 1 each to
1016
make them grow and shrink equally with the sizer's horizontal dimension.
1017
:param `flag`: this parameter can be used to set a number of flags which can be combined using the binary OR operator ``|``.
1018
Two main behaviours are defined using these flags. One is the border around a window: the border parameter determines the border
1019
width whereas the flags given here determine which side(s) of the item that the border will be added. The other flags determine
1020
how the sizer item behaves when the space allotted to the sizer changes, and is somewhat dependent on the specific kind of sizer used:
1022
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+
1023
| Sizer Flag | Description |
1024
+=====================================================================+=============================================================================+
1025
| ``wx.TOP`` | These flags are used to specify which side(s) of the sizer |
1026
+---------------------------------------------------------------------+ item the border width will apply to. |
1028
+---------------------------------------------------------------------+ |
1030
+---------------------------------------------------------------------+ |
1032
+---------------------------------------------------------------------+ |
1034
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+
1035
| ``wx.EXPAND`` | The item will be expanded to fill the space assigned to |
1037
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+
1038
| ``wx.SHAPED`` | The item will be expanded as much as possible while also |
1039
| | maintaining its aspect ratio |
1040
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+
1041
| ``wx.FIXED_MINSIZE`` | Normally `wx.Sizers` will use |
1042
| | `wx.Window.GetAdjustedBestSize` to |
1043
| | determine what the minimal size of window items should be, and will use that|
1044
| | size to calculate the layout. This allows layouts to adjust when an item |
1045
| | changes and its best size becomes different. If you would rather have a |
1046
| | window item stay the size it started with then use ``wx.FIXED_MINSIZE``. |
1047
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+
1048
| ``wx.RESERVE_SPACE_EVEN_IF_HIDDEN`` | Normally `wx.Sizers` don't allocate space for hidden windows or other items.|
1049
| | This flag overrides this behavior so that sufficient space is allocated for |
1050
| | the window even if it isn't visible. This makes it possible to dynamically |
1051
| | show and hide controls without resizing parent dialog, for example. This |
1052
| | function is new since wxWidgets version 2.8.8 |
1053
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+
1054
| ``wx.ALIGN_CENTER`` **or** ``wx.ALIGN_CENTRE`` | The ``wx.ALIGN*`` flags allow you to specify the alignment of the item |
1055
+---------------------------------------------------------------------+ within the space allotted to it by the sizer, adjusted for the border if |
1056
| ``wx.ALIGN_LEFT`` | any. |
1057
+---------------------------------------------------------------------+ |
1058
| ``wx.ALIGN_RIGHT`` | |
1059
+---------------------------------------------------------------------+ |
1060
| ``wx.ALIGN_TOP`` | |
1061
+---------------------------------------------------------------------+ |
1062
| ``wx.ALIGN_BOTTOM`` | |
1063
+---------------------------------------------------------------------+ |
1064
| ``wx.ALIGN_CENTER_VERTICAL`` **or** ``wx.ALIGN_CENTRE_VERTICAL`` | |
1065
+---------------------------------------------------------------------+ |
1066
| ``wx.ALIGN_CENTER_HORIZONTAL`` **or** ``wx.ALIGN_CENTRE_HORIZONTAL``| |
1067
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+
1069
:param `border`: determines the border width, if the flag parameter is set
1070
to include any border flag.
1071
:param `userData`: Allows an extra object to be attached to the sizer item,
1072
for use in derived classes when sizing information is more complex than the
1073
proportion and flag will allow for.
1075
:note: there is no support for `userData` parameter if `item` is a pseudocontrol,
1076
since that is already used.
1002
1079
# check to see if it's a pseudo object or sizer
1003
1080
if isinstance(item, Sizer):