Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add widgets inside a StaticBox, wxPython?

it is possible to add things into a StaticBox, in wxPython? I know this is a rather simple question however I cannot seem to find anything on Google. I would like to actually be able to add things into the StaticBox, such as buttons.


1 Answers

Looking at the code from one of my old projects, it looks like I used a StaticBoxSizer, and added the elements to this sizer. Quick test:

app = wx.App(redirect=False)
frame = wx.Frame(None)
static_box = wx.StaticBox(frame, label='Label')
sizer = wx.StaticBoxSizer(static_box, wx.VERTICAL)

for i in range(5):
    sizer.Add(wx.Button(frame, label='Button ' + str(i)))

frame.Sizer = sizer
frame.Sizer.Fit(frame)
frame.Show()
app.MainLoop()
like image 51
Bastien Léonard Avatar answered Jul 15 '26 13:07

Bastien Léonard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!