wxPython: Making something expand

python, user-interface, wxpython

Solution

The short answer: use a sizer with a proportion of 1 and the wx.Expand tag.

So here I am in the init of a panel

sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.canvas, 1, wx.EXPAND)
self.SetSizer(sizer)

Problem

How do I make any wxPython widget (like wx.Panel or wx.Button) automatically expand to fill its parent window?

Original source