I had created a wxComboBox and I want the text entered in the combobox to be limited to numeric only. I don't want to do this via the EVT_TEXT event, but via a validator. In other words I want to do this through the EVT_CHAR event handled in the validator. I tried to do the same thing as shown in the demo (in the validor example) but with no success. What should I do?
Thanx for your help.
Give more details and perhaps a working sample that shows the problem.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
In my experience, validators can be tricky to get right. You can try
looking at the implementation of wxIntCtrl in wxPython2.4.0.2
(lib/intctrl.py); I wrote this to do the same thing you want, but
in a wxTextCtrl rather than the wxComboBox. The semantics, however,
should be similar.
Alternatively, Jeff Childers and I are working on a set of masked
edit controls, including a wxMaskedComboBox that should also be
able to do what you want. It allows you to do validation on the
text such that the value entered must be a number, and allows you to
additionally verify that the number entered is one of the values
in the choice list. We hope to have the classes ready for
submission soon, so if you can afford to wait until the next
wxPython release, you can use that. I presume there's a finite
list of valid numeric choices for your application?
Regards,
/Will Sadkin
Parlance Corporation