title: How to understand wxGridBagSizer?
body: <p>I was trying to design gui for my app using wxPython. 
  I was using wx.GridBagSizer, but I encountered a few problems with it. </p>
  
  <p><img src="https://i.stack.imgur.com/sugN6.jpg" alt="enter image description here"></p>
  
  <p>First layout is what I get from my code and the second one is the layout I would like to get. I think I don't understand pos and span attributes correctly. I would be grateful for any explanation. Below is my current code:</p>
  
  <pre><code>class MyFrame1 ( wx.Frame ):
  
  def __init__( self, parent ):
      wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 561,401 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
  
      self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
  
      gbSizer1 = wx.GridBagSizer( 0, 0 )
      gbSizer1.SetFlexibleDirection( wx.BOTH )
      gbSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
  
      gbSizer1.SetMinSize( wx.Size( 0,0 ) ) 
      self.m_panel25 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 10,10 ), wx.TAB_TRAVERSAL )
      self.m_panel25.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOWTEXT ) )
  
      gbSizer1.Add( self.m_panel25, wx.GBPosition( 0, 0 ), wx.GBSpan( 1, 3 ), wx.EXPAND |wx.ALL, 5 )
  
      self.m_panel41 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
      gbSizer1.Add( self.m_panel41, wx.GBPosition( 5, 0 ), wx.GBSpan( 1, 1 ), wx.EXPAND |wx.ALL, 5 )
  
      self.m_panel26 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 10,10 ), wx.TAB_TRAVERSAL )
      self.m_panel26.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INFOBK ) )
  
      gbSizer1.Add( self.m_panel26, wx.GBPosition( 0, 3 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 )
  
      self.m_panel28 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 10,10 ), wx.TAB_TRAVERSAL )
      self.m_panel28.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INFOBK ) )
  
      gbSizer1.Add( self.m_panel28, wx.GBPosition( 0, 4 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 )
  
      self.m_panel27 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 10,10 ), wx.TAB_TRAVERSAL )
      self.m_panel27.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INFOBK ) )
  
      gbSizer1.Add( self.m_panel27, wx.GBPosition( 0, 5 ), wx.GBSpan( 1, 1 ), wx.ALL, 5 )
  
      self.m_panel29 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 10,10 ), wx.TAB_TRAVERSAL )
      self.m_panel29.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INFOBK ) )
  
      gbSizer1.Add( self.m_panel29, wx.GBPosition( 0, 6 ), wx.GBSpan( 1, 3 ), wx.EXPAND |wx.ALL, 5 )
  
      self.m_panel30 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 10,10 ), wx.TAB_TRAVERSAL )
      self.m_panel30.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INFOTEXT ) )
  
      gbSizer1.Add( self.m_panel30, wx.GBPosition( 1, 3 ), wx.GBSpan( 5, 6 ), wx.EXPAND |wx.ALL, 5 )
  
      self.m_panel31 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 10,10 ), wx.TAB_TRAVERSAL )
      self.m_panel31.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHT ) )
  
      gbSizer1.Add( self.m_panel31, wx.GBPosition( 1, 0 ), wx.GBSpan( 1, 3 ), wx.ALL, 5 )
  
      self.m_panel32 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 10,10 ), wx.TAB_TRAVERSAL )
      self.m_panel32.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHT ) )
  
      gbSizer1.Add( self.m_panel32, wx.GBPosition( 2, 0 ), wx.GBSpan( 1, 3 ), wx.ALL, 5 )
  
      self.m_panel39 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 10,10 ), wx.TAB_TRAVERSAL )
      self.m_panel39.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHT ) )
  
      gbSizer1.Add( self.m_panel39, wx.GBPosition( 3, 0 ), wx.GBSpan( 1, 3 ), wx.ALL, 5 )
  
      self.m_panel40 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 10,10 ), wx.TAB_TRAVERSAL )
      self.m_panel40.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHT ) )
  
      gbSizer1.Add( self.m_panel40, wx.GBPosition( 4, 0 ), wx.GBSpan( 1, 3 ), wx.ALL, 5 )
  
  
      self.SetSizer( gbSizer1 )
      self.Layout()
  
      self.Centre( wx.BOTH )
  </code></pre>