Adding Checkbox widget to panel distorts layout.

From the ScrolledPanel code & screenshot I posted yesterday (or the day before)

I have now added a CheckBox widget.
The checkbox is tiny, but is acting like it is as wide as the two
TextCtrl widgets, and as such,
pushes the TextCtrl widget out of alignment.

How do I align/position the Checkbox, so all 3 widgets are on the same line?

Attached are two screenshots showing before adding the checkbox after
adding the checkbox

class TestPanel(scrolled.ScrolledPanel):
   def __init__(self, parent):
      scrolled.ScrolledPanel.__init__(self, parent, -1)
      vbox = wx.BoxSizer(wx.VERTICAL)
      vbox.Add(wx.StaticLine(self, -1, size=(1024,-1)), 0, wx.ALL, 5)
      vbox.Add((20,20))
      tokenList = ['TOKENS'] * 100
      panel1 = scrolled.ScrolledPanel(self, -1, size=(300, 300), style
= wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER, name="panel1" )
      fgs1 = wx.FlexGridSizer(cols=2, vgap=4, hgap=4)

      for enum,token in enumerate(tokenList):
         tokeNum = ''.join([ '%4s' % str(enum+1), ': ', token, ':'])
         tokenName = wx.TextCtrl(panel1, -1, tokeNum, size=(75,-1))
         cb = wx.CheckBox(panel1, -1, '%4s' % str(enum+1), style=wx.ALIGN_RIGHT)

         tokenDef = wx.TextCtrl(panel1, -1, 'TOKEN_DEFINITION %4s' %
str(enum+1), size=(140,-1))
         tokenDef.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)

         fgs1.Add(tokenName, flag=wx.ALIGN_RIGHT |
wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border=10)
         fgs1.Add(tokenDef, flag=wx.RIGHT, border=10)
         fgs1.Add(cb, flag=wx.LEFT, border=0)

      panel1.SetSizer( fgs1 )
      panel1.SetAutoLayout(1)
      panel1.SetupScrolling()

      hbox = wx.BoxSizer(wx.HORIZONTAL)
      hbox.Add((20,20))
      hbox.Add(panel1, 0, wx.FIXED_MINSIZE)
      hbox.Add((40, 10))

      vbox.Add(hbox, 0)
      self.SetSizer(vbox)
      self.SetAutoLayout(1)
      self.SetupScrolling(scroll_x=False)

Tony Cappellini wrote:

From the ScrolledPanel code & screenshot I posted yesterday (or the day before)

I have now added a CheckBox widget.
The checkbox is tiny, but is acting like it is as wide as the two
TextCtrl widgets, and as such,
pushes the TextCtrl widget out of alignment.

How do I align/position the Checkbox, so all 3 widgets are on the same line?

Here is a clue:

···

      fgs1 = wx.FlexGridSizer(cols=2, vgap=4, hgap=4)

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!