wxpython - wx.GridBagSizer + wx.StaticBoxSizer: How to automate span calculation -


i have following following window generated using function called createstaticboxsizer staticbox3 contains empty spaces @ end of dont want to.

i contain no empty space. noticed if put span staticbox3 7 gives result want automate process of generating span opposed hard-coding it:

boxsizer containing space

the code uses span based on number of items creates, if creates 8 items within boxsizer, uses span of 8.

i can't understand why wrong can please clarify? should span corresponding to?

also staticbox::4 intruding on row of staticbox::1 why doesn't expand staticbox::3 does?

the code generate follows:

import wx import wx.lib.inspection class myregion(wx.frame):     = 0     def __init__(self, parent):         wx.frame.__init__(self, parent, title="my region")         gridsizer = wx.gridbagsizer()          gridsizer.add(self.createstaticboxsizer(4), pos=(0,0), span=(4,1), flag=wx.expand)         gridsizer.add(self.createstaticboxsizer(4), pos=(4,0), span=(4,1), flag=wx.expand)         gridsizer.add(self.createstaticboxsizer(4), pos=(0,1), span=(4,1), flag=wx.expand)         gridsizer.add(self.createstaticboxsizer(8), pos=(0,2), span=(8,1), flag=wx.expand)         gridsizer.add(self.createstaticboxsizer(6), pos=(0,3), span=(6,1), flag=wx.expand)          self.setsizer(gridsizer)      def createstaticboxsizer(self, x=4):         box = wx.staticbox(parent=self, label="staticbox::" + str(myregion.i))         myregion.i += 1         sz = wx.staticboxsizer(orient=wx.vertical, box=box)         in range(x):             sz.add(wx.statictext(parent=sz.getstaticbox(),                                  label="this window child of staticbox"))         return sz   if __name__ == "__main__":     app = wx.app()     frame = myregion(none)     frame.show()     wx.lib.inspection.inspectiontool().show()     app.mainloop() 

your sizer #3 has row span of 8, has same height of sum of sizers #0 , #1, , results in gap 2 sizers have 2 labels take more vertical space one.

there ways make work wxgridbagsizer imo sizer should (almost) never used anyhow. kind of normal layout should use wxflexgridsizer , wxboxsizer instead.


Popular posts from this blog