Jim Carroll wrote:
Hi, I'm just starting to use validators in my dialogs, and they work great when
I don't use XRC. If I do use xrc, then the validators have no effect. It's as
if the dialog can't walk through all the child windows and call their
validators. I even tried calling TransferDataToWindow() directly, with no
effect. Here's my example code. (I'll send a fully functioning example if
necessary)class EditItemDlg(wx.Dialog):
def __init__(self, parent, resource, itema = None):
wx.Dialog.__init__(self, parent, -1, "Work Item", size=wx.Size(400,320))self.itema = itema
self.res = resource
self.panel = self.res.LoadPanel(self, "EditWorkPanel")self.RequestedByText = xrc.XRCCTRL(self.panel, "RequestedByText")
validator = objVal.ObjectAttrTextValidator( self.itema, "contact", None,
True, self.validationCB)
self.RequestedByText.SetValidator(validator)
#...
self.Fit()
self.Layout()
# this should happen on InitDlg, but it doesn't even work when called
explicitly
self.TransferDataToWindow()
By default the validation is only done with the dialog's immediate children, but you've got a panel in between the dialog and the control with the validator. You can set the extra style wx.WS_EX_VALIDATE_RECURSIVELY of the dialog to get it to also validate the panel's children.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!