I find myself frequently using something like this to create a grid bag sizer that has a static box around it:
szDes = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Description"), wx.VERTICAL)
szD = wx.GridBagSizer(2, 2) # Sizer for the desc fields
szDes.Add(szD, flag=wx.ALIGN_CENTER|wx.EXPAND) # Place inside the box
So I thought to create a custom class called StaticBoxGridBagSizer but got stumped as to how to make the class behave like a GridBagSizer but yet place itself inside a static box. Here's as far as I got:
class StaticBoxGridBagSizer(wx.GridBagSizer):
def __init__(self, parent, label, vgap=0, hgap=0):
wx.GridBagSizer.__init__(vgap, hgap)
_sbs = wx.StaticBoxSizer(wx.StaticBox(self, -1, label), wx.VERTICAL)
#!! How do we place ourselves inside that static box sizer??
Is this a problem for multiple inheritance? Or is there some more sane way to have a GridBagSizer that happens to have a static box around it?
Side note: I find GridBagSizer to be by-far the most useful of the sizers, so having one with a static box around it would seem to be in the Really Useful (tm) category.
I find myself frequently using something like this to create a grid bag sizer that has a static box around it:
szDes = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Description"), wx.VERTICAL)
szD = wx.GridBagSizer(2, 2) # Sizer for the desc fields
szDes.Add(szD, flag=wx.ALIGN_CENTER|wx.EXPAND) # Place inside the box
So I thought to create a custom class called StaticBoxGridBagSizer but got stumped as to how to make the class behave like a GridBagSizer but yet place itself inside a static box. Here's as far as I got:
class StaticBoxGridBagSizer(wx.GridBagSizer):
def __init__(self, parent, label, vgap=0, hgap=0):
wx.GridBagSizer.__init__(vgap, hgap)
_sbs = wx.StaticBoxSizer(wx.StaticBox(self, -1, label), wx.VERTICAL)
#!! How do we place ourselves inside that static box sizer??
Is this a problem for multiple inheritance? Or is there some more sane way to have a GridBagSizer that happens to have a static box around it?
I think you have it inside-out. Try deriving your class from wx.StaticBoxSizer, give it a wx.GridBagSizer as an attribute and Add it to the StaticBoxSizer. Then you'll want to override sizer methods of the static box sizer and forward them to the grid bag sizer. This way when you use the sizer in a SetSizer call it will be the proper one. Something like this: