Sanity Check: wx.GridBagSizer

Through trial and error (as well as a lot of reading of the docs), I've
gotten somewhat closer ... I think. Here's how the class begins:

class modModel(wx.Panel):
   def _init_ctrls(self, prnt):

     gbs = self.gbs = wx.GridBagSizer(5,5)

     # generated method, don't edit
     wx.Panel.__init__(self, id=wxID_MODMODEL, name='modModel', parent=prnt,
           pos=wx.Point(382, 318), size=wx.Size(700, 500), style=wx.TAB_TRAVERSAL)
     self.SetToolTipString('Model information')
     self.SetClientSize(wx.Size(700, 500))

   Then I define the widgets. Below that I have:

     gbs.Add(self, wxID_MODMODELMODNAMELAB, (0,0), wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
     gbs.Add(self, wxID_MODMODELMODNAMETXT, (0,1), (0,2), wx.ALL, 5)
     gbs.Add(self, wxID_MODMODELMODDESCLAB, (0,3), wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
     gbs.Add(self, wxID_MODMODELMODDESCTXT, (0,4), (1,3), wx.ALL, 5)

   Without the 'self' I get all sorts of errors. Now, the error message is a
python error:

   File "/mnt/usr2/fuzzy/eikos/ui/modModel.py", line 139, in __init__
     gbs.Add(self, wxID_MODMODELMODNAMELAB, (0,0), wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
NameError: global name 'gbs' is not defined

   I thought that gbs was local; obviously python disagrees. How should I
define gbs in this context?

Thanks,

Rich

···

On Thu, 17 Nov 2005, E. A. Tacao wrote:

Do you mean GridBagSizer? If you do, you can just call a

gbs = self.gbs = wx.GridBagSizer(5, 5)

     gbs.Add(self, modNameLab, (0,0))

wxPython is wondering why are you trying to put 'self' 4 times inside
the same sizer...

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

'Window' as an attribute of the wx.GridBagSizer I thought was where the
widget was addded.

   When I get this module displaying properly, it should fit in the sequence:

wx.Frame -> wx.Panel -> wx.Notebook -> wx.Panel -> module with sizers and
widgets. No?

Thanks,

Rich

···

On Fri, 18 Nov 2005, E. A. Tacao wrote:

I'm sorry I didn't mentioned it earlier: 'window' is the thing you
want to put inside the sizer.

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

My test application showed me that the layout with a GridBagSizer was not
what I wanted. For example, the horizontal span of the wx.RadioBox stretched
the left-most column so the static text and text control above it were too
far apart.

Rich

···

On Fri, 18 Nov 2005, E. A. Tacao wrote:

If you are building some complex layout use GridBagSizer. Always.

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863