I followed the wxPyWiki cookbook and the wxPython demo code to produce the
following custom integer entry control. While the control seems to work
fine, when I put one on a dialog, and then do .ShowModal(), if I hit
"Cancel", the dialog goes away just fine; if I hit "Ok", the program
just crashes with "the instruction at <blah> could not be read."If I replace my validator with wxDefaultValidator, the dialog works
properly, so I'm pretty sure it's got something to do with that class.
...
I've included a complete program below which demonstrates the
problem. Could some wxPyrt please explain my error?
I can! I can! Is there a prize?
class IntValidator( wxPyValidator ):
...
def Validate(self, window):
window =wxPyTypeCast(window, "wxTextCtrl")
The doc for wxValidator.Validate states that the parameter you get is the
PARENT of the controls to be validated. In your case, it is an instance of
myDialog.
Replace that last line with this:
window = window.int_ctrl
and you should find joy.
ยทยทยท
On Thu, 10 Oct 2002 13:20:03 -0700, Will Sadkin <wsadkin@nameconnector.com> wrote:
try:
value = int( window.GetValue())
return true
except ValueError:
return false
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.