Search code examples
wxpython

How to format label in wxPython's StaticBox?


I want to set the label (header?) of the wx.StaticBox widget in a 16pt bold font.

For a normal wx.StaticText I would do this (thanks to this post):

my_font = wx.Font(16, wx.DEFAULT, wx.NORMAL, wx.BOLD)
text = wx.StaticText(self.panel, label='My Text')
text.SetFont(my_font)

How is this done for the wx.StaticBox?


Solution

  • This is not supported by wx.StaticBox as far as I can tell. You will need to create a custom widget to accomplish this. I would recommend reading the following article:

    The wxPython demo also has many examples of custom widgets. Check out anything in the "Custom Controls" or "Advanced Generic Widgets" sections for examples.