Hi,
Is there a way of modifying the label of a StaticBoxSizer on wxPython after initialization?
I couldn't find anything on wxPython's documentation.
Thank you
Hi,
Is there a way of modifying the label of a StaticBoxSizer on wxPython after initialization?
I couldn't find anything on wxPython's documentation.
Thank you
When you create a wx.StaticBoxSizer
, you must pass it a wx.StaticBox
as the first argument of the initializer, this is what you need to modify to change the label. If you look at the class hierarchies, they go as follows:
As you may have figured out, SetLabel
is not a method of the sizer or any of it's parents, it instead lives in the Control class, so the box inherits it.
# creating the static box sizer
self.my_box = wx.StaticBox(self.panel, wx.ID_ANY, "Spam, spam, spam")
self.sizer_static_box = wx.StaticBoxSizer(my_box)
# then do something like this later
self.my_box.SetLabel("I hate spam!")