[wxPython] Validator for TxtCtrl to trigger with a custom Button handler

F. GEIGER franz.geiger at fh-vorarlberg.ac.at
Thu Jul 22 07:53:42 EDT 2004


Sorry, must read:

def _onButton_(self, event):
   success = self._myTextCtrl.GetValidator().Validate()
   return

CAUTION: This code has never executed!

Of course, you have to supply _myTextCtrl with a validator upon creation.

Look at the wxPython demo: Core Windows Controls -> Validator. Have a look
into the help files, look for wxValidator.

HTH
Franz GEIGER

"Lo?c Mah?" <loic.mahe at free.fr> wrote in message
news:27a5ac50.0407220011.7c151a32 at posting.google.com...
> Your solution does not seem work, at least on my system!
> Does it works on your system ?
>
> I got a message telling me that:
>
> _myTextCtrl / self.tc has no Validate attribute
>
>
> I have:
> windows
> python 2.3.4
> wxpython 2.5.1
>
>
> I finnaly got a kind of ugly workaround to call the Validate() function:
>
> I had to replace:
> if self.Validate():
>
> by:
> if self.tc.GetValidator().Validate(self.tc):
>
> I find this quite ugly and not pythoninc at all,
> but this is the only solution I found yet!
>
> Loic
>
>
> "F. GEIGER" <franz.geiger at fh-vorarlberg.ac.at> wrote in message
news:<40fe5226$0$17706$3b214f66 at aconews.univie.ac.at>...
> > def _onButton_(self, event):
> >    success = self._myTextCtrl.Validate()
> >    return
> >
> > self is the Frame here. _onButton_ therefore belongs to the frame and
was
> > bound with wx.Button.Bind.
> >
> > HTH
> > F. GEIGER
> >





More information about the Python-list mailing list