[wxPython-users] Re: Custom validator

Robin Dunn robin at alldunn.com
Tue Jan 2 09:00:09 PST 2007


Basil Shubin wrote:
> Hi,
> 
> Phil Mayes пишет:
>>
>> Try:
>> FLOAT = r'\d+\.\d+$'
> 
> Not exactly what it should be. The problem is that I want check all 
> input char and 'allow' only digits, but all digits should fit the regex 
> pattern. For checking where is pressed key correspond the digits, is to 
> bind on wx.EVT_CHAR and than check if key is digit (it's showed in 
> wxPython validator example). But I don't know how I can check the entire 
> inputed string, so it fits regex pattern.

Normally something like that would be done in the Validate method, but 
that is not called for every character, only when the dialog is 
completed.  You don't want to do it in the EVT_CHAR handler since the 
new char has not been inserted into textctrl yet.  But you could use 
wx.CallAfter from there to cause a method to be called after the 
character has been inserted, and from there you can get the value of the 
control and check it however you like.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list