Author: bugman Date: Tue Jun 14 14:46:39 2011 New Revision: 12984 URL: http://svn.gna.org/viewcvs/relax?rev=12984&view=rev Log: The gui.misc.add_border() function no longer packs the box in the parent and detects orientation. The parent argument has been replaced by a box sizer argument. Modified: 1.3/gui/misc.py Modified: 1.3/gui/misc.py URL: http://svn.gna.org/viewcvs/relax/1.3/gui/misc.py?rev=12984&r1=12983&r2=12984&view=diff ============================================================================== --- 1.3/gui/misc.py (original) +++ 1.3/gui/misc.py Tue Jun 14 14:46:39 2011 @@ -30,11 +30,11 @@ import wx -def add_border(parent, border=0, packing=wx.VERTICAL): +def add_border(box, border=0, packing=wx.VERTICAL): """Create the main part of the frame, returning the central sizer. - @param parent: The parent GUI element to pack the box into. - @type parent: wx object + @param box: The box sizer element to pack the borders into. + @type box: wx.BoxSizer instance @keyword border: The size of the border in pixels. @type border: int @keyword packing: Specify if the central sizer should be vertically or horizontally packed. @@ -43,23 +43,26 @@ @rtype: wx.BoxSizer instance """ + # The orientation of the sub sizer. + orient = box.GetOrientation() + if orient == wx.HORIZONTAL: + orient_sub = wx.VERTICAL + else: + orient_sub = wx.HORIZONTAL + # Some sizers. - sizer_hori = wx.BoxSizer(wx.HORIZONTAL) - sizer_vert = wx.BoxSizer(wx.VERTICAL) + sizer_sub = wx.BoxSizer(orient_sub) sizer_cent = wx.BoxSizer(packing) - # Pack the sizer into the frame. - parent.SetSizer(sizer_hori) - # Left and right borders. - sizer_hori.AddSpacer(border) - sizer_hori.Add(sizer_vert, 1, wx.EXPAND|wx.ALL) - sizer_hori.AddSpacer(border) + box.AddSpacer(border) + box.Add(sizer_sub, 1, wx.EXPAND|wx.ALL) + box.AddSpacer(border) # Top and bottom borders. - sizer_vert.AddSpacer(border) - sizer_vert.Add(sizer_cent, 1, wx.EXPAND|wx.ALL) - sizer_vert.AddSpacer(border) + sizer_sub.AddSpacer(border) + sizer_sub.Add(sizer_cent, 1, wx.EXPAND|wx.ALL) + sizer_sub.AddSpacer(border) # Return the central sizer. return sizer_cent