Search code examples
pythonwxpythonsizeswtpack

Equivalent for SWT's .pack() in wxPython?


In wxPython, is there a short form of:

size = object.GetBestSize()
object.SetSize(size)

(For controls or for frames and dialogs.) .Layout() only adjusts the sizes of the child controls.

In SWT there's .pack() for this.


Solution

  • Unless you set the size of the widget explicitly, they generally already adjust to the right size. If you add widgets to a sizer and tell them to stretch, then that won't be the case, of course. You can also use the sizer's Fit() method to force it too, although I rarely think this is necessary.