开发者

Modify StaticBoxSizer label on wxPython

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:

  • object -> Object -> EvtHandler -> Window -> Control -> StaticBox
  • object -> Object -> Sizer -> BoxSizer -> StaticBoxSizer

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(self.my_box)

# then do something like this later        
self.my_box.SetLabel("I hate spam!")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜