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.
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. |
|
The item will be expanded to fill the space assigned to the item. |
|
The item will be expanded as much as possible while also maintaining its aspect ratio |
|
Normally wx.Sizers will use
|
|
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 |
The constructor. |
|
Appends a child to the sizer. |
|
|
|
This base function adds non-stretchable space to both the horizontal and vertical orientation of the sizer. |
|
Adds stretchable space to the sizer. |
|
This method is abstract and has to be overwritten by any derived class. |
|
Detaches all children from the sizer. |
|
Computes client area size for window so that it matches the sizer’s minimal size. |
|
Like |
|
Detach the child window from the sizer without destroying it. |
|
Tell the sizer to resize the window so that its client area matches the sizer’s minimal size ( |
|
Tell the sizer to resize the virtual size of the window to match the sizer’s minimal size. |
|
Returns the list of the items in this sizer. |
|
Returns the window this sizer is used in or |
|
Finds the wx.SizerItem which holds the given window. |
|
Finds the item in the sizer which has the given id. |
|
Returns the number of items in the sizer. |
|
Returns the minimal size of the sizer. |
|
Returns the current position of the sizer. |
|
Returns the current size of the sizer. |
|
Hides the child window. |
|
Inform sizer about the first direction that has been decided (by parent item). |
|
Insert a child into the sizer before any existing item at index. |
|
Inserts non-stretchable space to the sizer. |
|
Inserts stretchable space to the sizer. |
|
Return |
|
Returns |
|
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. |
|
Same as |
|
Prepends non-stretchable space to the sizer. |
|
Prepends stretchable space to the sizer. |
|
This is a deprecated version of RepositionChildren() |
|
Removes a sizer child from the sizer and destroys it. |
|
Detaches the given oldwin from the sizer and replaces it with the given newwin. |
|
Method which must be overridden in the derived sizer classes. |
|
Set the window this sizer is used in. |
|
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 |
|
Set an item’s minimum size by window, sizer, or position. |
|
Call this to give the sizer a minimal size. |
|
This method first calls |
|
Shows or hides the window. |
|
Show or hide all items managed by the sizer. |
|
A Python convenience method that allows Sizers to act as iterables that will yield their wx.SizerItems. |
|
Can be used to test if the C++ part of the sizer still exists, with |
See |
|
See |
|
See |
|
See |
|
See |
wx.
Sizer
(Object)¶Possible constructors:
Sizer()
Sizer is the abstract base class used for laying out subwindows in a window.
__init__
(self)¶The constructor.
Note that wx.Sizer is an abstract base class and may not be instantiated.
Add
(self, *args, **kw)¶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:
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.
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:
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.
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:
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.
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:
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.
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.
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.
Add (self, width, height, flags)
Appends a spacer child to the sizer.
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.
Add (self, item)
item (wx.SizerItem) –
Add (self, size, proportion=0, flag=0, border=0, /Transfer/=None)
Add a spacer using a Size
object.
Add (self, size, flags)
Add a spacer using a Size
object.
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)
size (int) –
See also
AddStretchSpacer
(self, prop=1)¶Adds stretchable space to the sizer.
More readable way of calling:
wx.Sizer.Add(0, 0, proportion)
prop (int) –
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.
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).
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
.
New in version 2.8.8.
See also
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
.
New in version 2.8.8.
See also
Detach
(self, *args, **kw)¶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.
window (wx.Window) –
bool
See also
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.
sizer (wx.Sizer) –
bool
See also
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 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.
index (int) –
bool
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.
See also
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.
window (wx.Window) –
See also
wx.Scrolled.SetScrollbars
, SetVirtualSizeHints
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.
SizerItemList
GetContainingWindow
(self)¶Returns the window this sizer is used in or None
if none.
GetItem
(self, *args, **kw)¶GetItem (self, window, recursive=False)
Finds the wx.SizerItem which holds the given window.
Use parameter recursive to search in subsizers too.
window (wx.Window) –
recursive (bool) –
Pointer to the item or None
if there is no item with the window.
GetItem (self, sizer, recursive=False)
Finds the wx.SizerItem which holds the given sizer.
Use parameter recursive to search in subsizers too.
sizer (wx.Sizer) –
recursive (bool) –
Pointer to the item or None
if the given sizer is not in the sizer.
GetItem (self, index)
Finds the wx.SizerItem which is located in the sizer at position index.
index (int) –
Pointer to the item or None
if there is no item at that index.
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 wx.SizerItem itself. This is mainly useful for retrieving the sizers created from XRC
resources. Use parameter recursive to search in subsizers too.
id (int) –
recursive (bool) –
Pointer to item or None
if no item has that id.
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 IsEmpty
function.
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
.
Hide
(self, *args, **kw)¶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.
window (wx.Window) –
recursive (bool) –
bool
See also
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.
sizer (wx.Sizer) –
recursive (bool) –
bool
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).
direction (int) –
size (int) –
availableOtherDir (int) –
bool
Insert
(self, *args, **kw)¶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.
index (int) –
window (wx.Window) –
flags (wx.SizerFlags) –
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.
index (int) –
window (wx.Window) –
proportion (int) –
flag (int) –
border (int) –
userData (PyUserData) –
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.
index (int) –
sizer (wx.Sizer) –
flags (wx.SizerFlags) –
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.
index (int) –
sizer (wx.Sizer) –
proportion (int) –
flag (int) –
border (int) –
userData (PyUserData) –
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.
index (int) –
width (int) –
height (int) –
proportion (int) –
flag (int) –
border (int) –
userData (PyUserData) –
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.
index (int) –
width (int) –
height (int) –
flags (wx.SizerFlags) –
Insert (self, index, item)
index (int) –
item (wx.SizerItem) –
Insert (self, index, size, proportion=0, flag=0, border=0, /Transfer/=None)
Insert a spacer using a Size
object.
Insert (self, index, size, flags)
Insert a spacer using a Size
object.
InsertSpacer
(self, index, size)¶Inserts non-stretchable space to the sizer.
More readable way of calling Sizer.Insert(index, size, size).
index (int) –
size (int) –
InsertStretchSpacer
(self, index, prop=1)¶Inserts stretchable space to the sizer.
More readable way of calling Sizer.Insert(0, 0, prop).
index (int) –
prop (int) –
IsEmpty
(self)¶Return True
if the sizer has no elements.
bool
See also
IsShown
(self, *args, **kw)¶IsShown (self, window)
Returns True
if the window is shown.
window (wx.Window) –
bool
See also
Hide
, Show
, wx.SizerItem.IsShown
IsShown (self, sizer)
Returns True
if the sizer is shown.
sizer (wx.Sizer) –
bool
See also
Hide
, Show
, wx.SizerItem.IsShown
IsShown (self, index)
Returns True
if the item at index is shown.
index (int) –
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)¶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.
window (wx.Window) –
flags (wx.SizerFlags) –
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.
window (wx.Window) –
proportion (int) –
flag (int) –
border (int) –
userData (PyUserData) –
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.
sizer (wx.Sizer) –
flags (wx.SizerFlags) –
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.
sizer (wx.Sizer) –
proportion (int) –
flag (int) –
border (int) –
userData (PyUserData) –
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.
width (int) –
height (int) –
proportion (int) –
flag (int) –
border (int) –
userData (PyUserData) –
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.
width (int) –
height (int) –
flags (wx.SizerFlags) –
Prepend (self, item)
item (wx.SizerItem) –
Prepend (self, size, proportion=0, flag=0, border=0, /Transfer/=None)
Prepend a spacer using a Size
object.
Prepend (self, size, flags)
Prepend a spacer using a Size
object.
PrependSpacer
(self, size)¶Prepends non-stretchable space to the sizer.
More readable way of calling Sizer.Prepend(size, size, 0).
size (int) –
PrependStretchSpacer
(self, prop=1)¶Prepends stretchable space to the sizer.
More readable way of calling Sizer.Prepend(0, 0, prop).
prop (int) –
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.
Remove
(self, *args, **kw)¶Remove (self, sizer)
Removes a sizer child from the sizer and destroys it.
bool
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).
index (int) – The position of the child in the sizer, e.g. 0 for the first item.
bool
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)¶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.
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.
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.
index (int) –
newitem (wx.SizerItem) –
bool
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 CalcMin
.
Note that you should never call this method directly, call Layout
instead if you need to manually update the sizer elements positions. This method is only called by wxWidgets itself.
minSize (wx.Size) –
New in version 4.1/wxWidgets-3.1.3: , before this version RecalcSizes() method not taking any arguments had to be overridden in the derived classes instead.
SetContainingWindow
(self, window)¶Set the window this sizer is used in.
window (wx.Window) –
SetDimension
(self, *args, **kw)¶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.
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.
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.
True
if the minimal size was successfully set or False
if the item was not found.
See also
SetItemMinSize (self, window, width, height)
window (wx.Window) –
width (int) –
height (int) –
bool
SetItemMinSize (self, window, size)
SetItemMinSize (self, sizer, width, height)
sizer (wx.Sizer) –
width (int) –
height (int) –
bool
SetItemMinSize (self, sizer, size)
SetItemMinSize (self, index, width, height)
index (int) –
width (int) –
height (int) –
bool
SetItemMinSize (self, index, size)
index (int) –
size (wx.Size) –
bool
SetMinSize
(self, *args, **kw)¶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.
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.
width (int) –
height (int) –
SetSizeHints
(self, window)¶This method first calls Fit
and then wx.TopLevelWindow.SetSizeHints
on the window passed to it.
This function is only 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.
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 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 BoxSizer overview.
window (wx.Window) –
Show
(self, *args, **kw)¶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.
window (wx.Window) –
show (bool) –
recursive (bool) –
bool
See also
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.
sizer (wx.Sizer) –
show (bool) –
recursive (bool) –
bool
ShowItems
(self, show)¶Show or hide all items managed by the sizer.
show (bool) –
__iter__
(self)¶A Python convenience method that allows Sizers to act as iterables that will yield their wx.SizerItems.
__nonzero__
(self)¶Can be used to test if the C++ part of the sizer still exists, with code like this:
if theSizer:
doSomething()
Children
¶See GetChildren
ContainingWindow
¶ItemCount
¶See GetItemCount
MinSize
¶See GetMinSize
and SetMinSize
Position
¶See GetPosition