Search code examples
wxpythonwxwidgets

wxPython How are the different sizes used in a wx.Window


  1. Is there a document as to how these sizes are used in wxPython?
  2. What state must the window be in for these sizes to be valid? Hidden, maximized, minimized etc...

    GetBestSize()

    GetEffectiveMinSize()

    GetMaxSize()

    GetMinSize()

    GetSize()

I find this very tricky as there are many size methods and I am not sure how they are used.


Solution

  • I think the best and most up to date documentation is the one for the wxPython Phoenix project.

    http://wxpython.org/Phoenix/docs/html/Window.html?highlight=getsize#Window.GetBestSize

    Most of that documentation also applies to the wxPython Classic version, especially if you use wxPython 2.9 or newer.

    Note that all overloaded methods have different names in the Classic version where as in Phoenix there is just one name - most of this and more is documented here: http://wxpython.org/Phoenix/docs/html/classic_vs_phoenix.html

    The wiki might also be helpful, in particular: wiki.wxpython.org/WindowSizeInfo

    With regards to 2., as soon as the window/control is created you will get a value. Is that valid? Yes, but if you use sizers and if the layout is not yet updated you might get default values (0, 0) or (20, 20).

    If you use sizers to control your layout you should never or very very rarely care about the size of a control.