Validating controls placed in subpanels

A.M. cuberootva at gmail.com
Mon Jul 10 10:38:45 PDT 2006


Hello,

I am having a problem getting Validation routines to work with
controls that are not "owned" by the top level form. Maybe that is how
it is supposed to be but I thought I would throw it out there anyway.

Below is a sample of something very similar to what I am doing. The
Validator object is a subclass of PyValidator that provides the
Validate, Clone, TransferToWindow, and TransferFromWindow functions.

# self is a PyWizardPage

# BEGIN

# setup the scrolled panel
sp = ScrolledPanel.ScrolledPanel(self, -1, size=(w,h))
spsizer = wx.BoxSizer(wx.VERTICAL)
sp.SetSizer(spsizer)
sp.SetAutoLayout(1)
sp.SetupScrolling()

# add a control
s = wx.BoxSizer(wx.HORIZONTAL)
s.Add(wx.StaticText(sp, -1, "Label"), 2)
s.Add(wx.TextCtrl(sp, -1, validator=Validator.Validator("value")), 2)

spsizer.Add(s, flag=wx.EXPAND)
spsizer.Add((0, 20), flag=wx.EXPAND)

# add the scrolled panel to the wizard page's sizer
self._sizer.Add(sp, 0, wx.EXPAND)
self.Layout()

# END

The line above where I add the TextCtrl as is will not call any of the
Validate methods, however, if I change the owner from the scrolled
panel (sp) to the wizard page (self) all is well. Doing this though
will cause the layout of the text control and label to be off and NOT
part of the scrolled panel.

Any suggestions? I am at a loss...

Thanks,

Abe




More information about the wxpython-users mailing list