hello!
i am unable to get a validator working with wxDialog. the following
small example shows that neither of validator methods are called
automatically:
=== cut ===
from wxPython import wx
class MyValidator(wx.wxPyValidator):
def __init__(self, code):
wx.wxPyValidator.__init__(self)
self.code = code
def Clone(self):
print "Clone", self.code
return MyValidator(self.code)
def TransferToWindow(self):
print "TransferToWindow", self.code
return 1
def Validate(self, win):
print "validate", self.code, win
return 1
def TransferFromWindow(self):
print "TransferFromWindow", self.code
return 1
class TestApp(wx.wxApp):
def OnInit(self):
_dlg = wx.wxDialog(wx.NULL, -1, "Dialog", size=(100, 100))
wx.wxButton(_dlg, wx.wxID_OK, "Close", size=(50, 50))
_dlg.SetValidator(MyValidator(1))
_dlg.ShowModal()
_dlg.Destroy()
return 0
if __name__ == "__main__":
app = TestApp(0)
app.MainLoop()
=== cut ===
tested with wxPython 2.3.3pre3 on win32 and 2.3.2.1 on GTK.
it is possible to call the validator manually in OnInitDialog and OnOK
event handlers, but is it the only way to make validator work?
best wishes,
alex.