WxPython: how to make TextCtrl fill a panel

How to set the size of a multi-line TextCtrl to always fill its parent panel?

+5
source share
1 answer

Use boxSizer.

When you add textCtrlyours to sizer, set the proportion 1and pass the flag wx.EXPAND, so yours textCtrlshould fill the panel, even when the panel is resized

bsizer = wx.BoxSizer()
bsizer.Add(yourTxtCtrl, 1, wx.EXPAND)

At the end of initializing your panels, place the following command to set the layout

self.SetSizerAndFit(bsizer)
+9
source

All Articles