From: Brian D. <deb...@ho...> - 2005-02-28 13:37:07
|
Hi there, I was working on my text length limited widget, also I worked on a text field that only accepts numbers, and this is my code, hope it helps. def on_initialize(self, event): self.type = True def on_txtText_keyPress(self, event): keyCode = event.keyCode if keyCode in range(48,58) or keyCode in [8,316,317,318,319,127,314,315]: event.Skip() def on_txtText_keyPress(self, event): keyCode = event.keyCode if len(self.components.txtText.text) == 10: if keyCode in [8,316,317,318,319,127,314,315]: self.type = True else: self.type = False else: self.type = True if self.type: event.Skip() else: self.type = True Any suggestions or ideas on how to optmize this code, specially the text leght validation, are more than welcome. Regards, Brian _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ |