[wxPython-users] Re: PyValidator and floats, howto?

Werner F. Bruhin werner.bruhin at free.fr
Sun Jan 21 02:05:01 PST 2007


Hi Basil,

Basil Shubin wrote:
> Hi Werner and other,
>
> Werner F. Bruhin wrote:
>>> Alas, my question stays unanswered, but if there is no solution for 
>>> PyValidator, the masked control is my last chance.
>> Maybe you find your answer with the masked controls, as they do 
>> validation.   I assume you know about the wxPython validator demo 
>> under Core Windows/Controls.
>>
>> Maybe posting a small runnable sample will get some people to review 
>> and suggest changes.
>
> Here is test app. Main problem that I can enter as many '.' signs as I 
> want :-), but in ideal this should not happens.
>
> But what is purpose of Validator method after all?
You just can not insult it, otherwise it will not do it's job ;-) .

I removed the '.' from numList and
I changed:
        if not wx.Validator_IsSilent():
to:
        if not self.Validate(self):

Then you need to put some code into Validate to allow the first '.' but 
no more and put up some error message.

I don't know why wx.Validator_IsSilent() does not do the trick, maybe 
Robin can explain this.

Werner





More information about the wxpython-users mailing list