Debugging Dialog: Clue Needed

I extracted the dialog box below from the notebook page in which it is
embedded in order to make it appear when called. Python tells me that the
wx.StaticText's first argument should be a wxWindow, not the dialog itself.

   What simple things have I missed here?

   In the application this dialog box should appear when the 'Add' button on
the notebook page is selected.

Rich

···

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc.(TM) | Accelerator
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
--------------------------------------------------------------------------
#!/usr/bin/env python

import wx
from pysqlite2 import dbapi2 as sqlite3

class varDlg(wx.Dialog): # Used to add a new variable
   def __init__(self, parent, ID, title, size=wx.DefaultSize,
                pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE):

     sizer = wx.BoxSizer(wx.VERTICAL)

     box1 = wx.BoxSizer(wx.HORIZONTAL)
     nameLab = wx.StaticText(self, wx.ID_ANY, pos=(20, 5))
     varName = wx.TextCtrl(self, wx.ID_ANY, pos=(50, 5), size=(125, 25),
                           style=wx.TAB_TRAVERSAL|wx.RAISED_BORDER)
     box1.Add(nameLab, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     box1.Add(varName, 1, wx.ALIGN_CENTRE|wx.ALL, 5)
     sizer.Add(box1, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
     box2 = wx.BoxSizer(wx.HORIZONTAL)

     varDesc = wx.TextCrl(self, wx.ID_ANY, pos=(225, 5), size=(125,25),
     style=wx.TAB_TRAVERSAL|wx.RAISED_BORDER)
     box2.Add(descLab, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     box2.Add(varDesc, 1, wx.ALIGN_CENTRE|wx.ALL, 5)

     sizer.Add(box2, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

     box3 = wx.BoxSizer(wx.HORIZONTAL)
     polLab = wx.StaticText(self, wx.ID_ANY, pos=(20, 40))
     polName = wx.TextCrl(self, wx.ID_ANY, pos=(50, 40), size=(125,25),
     style=wx.TAB_TRAVERSAL|wx.RAISED_BORDER)
     box3.Add(polLab, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     box3.Add(varName, 1, wx.ALIGN_CENTRE|wx.ALL, 5)

     sizer.Add(box3, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

     box4 = wx.BoxSizer(wx.HORIZONTAL)
     subLab = wx.StaticText(self, wx.ID_ANY, pos=(200, 40))
     subName = wx.TextCrl(self, wx.ID_ANY, pos=(225, 40), size=(125,25),
     style=wx.TAB_TRAVERSAL|wx.RAISED_BORDER)
     box4.Add(subLab, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
     box4.Add(subName, 1, wx.ALIGN_CENTRE|wx.ALL, 5)

     sizer.Add(box4, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

     line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
     sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)

     btnsizer = wx.StdDialogButtonSizer()
     OkButton = wx.Button(self, wx.ID_OK, 'OK', pos=(150, 60))
     cancelButton = wx.Button(self, wx.ID_CANCEL, 'Cancel', pos(250, 60))
     OkButton.SetDefault()
     btnsizer.AddButton(OkButton)
     btnsizer.AddButton(cancelButton)

     sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

     self.SetSizer(sizer)
     sizer.Fit(self)
     # bound methods start here.
# end of class varDlg

if __name__ == '__main__':
   app = wx.App()
   myd = varDlg(None, -1, "Add a Variable")
   myd.Show(True)
   app.MainLoop()

Rich Shepard wrote:

  I extracted the dialog box below from the notebook page in which it is
embedded in order to make it appear when called. Python tells me that the
wx.StaticText's first argument should be a wxWindow, not the dialog itself.

  What simple things have I missed here?

It looks like you never called the wx.Dialog.__init__ in your init. That may be your problem.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Chris,

   Yes, this was part of it. I changed from using the wx.Dialog.__init__ to a
form in a different example. Doesn't work.

Many thanks,

Rich

···

On Wed, 8 Nov 2006, Christopher Barker wrote:

It looks like you never called the wx.Dialog.__init__ in your init. That
may be your problem.

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc.(TM) | Accelerator
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863