[Tutor] chr() and extended ASCII?

Liam Clarke cyresse at gmail.com
Sat Apr 9 14:09:36 CEST 2005


Hi all, 

Just working on some validators for text fields, and I started getting 
unusual errors - 

File "C:\Python23\lib\site-packages\PythonCard\components\textfield.py", 
line 338, in _dispatch
widget.Widget._dispatch(self, aWxEvent)
File "C:\Python23\lib\site-packages\PythonCard\widget.py", line 402, in 
_dispatch
handler(background, aWxEvent)
File "C:\Python23\SEDB\generic.py", line 53, in on_keyPress
elif len(eventSourceWidget.text) >=
self.restrictions[eventSourceWidget.name<http://eventSourceWidget.name>]['length']
or not self.isOK(eventSourceWidget.name <http://eventSourceWidget.name>, 
event.keyCode):
File "C:\Python23\SEDB\generic.py", line 69, in isOK
xR = self.integerRE.search(chr(keyCode))
ValueError: chr() arg not in range(256)

(And yes, I know wxPython has validators already, I was 90% through mine 
when I found them, and so I'll finish off the last 10% out of stubborn 
pride.)

For the life of me, I couldn't figure out what was happening, so I stuck in 
a try clause. 

*******
Oops
keyCode = 333
Widget = dateBooked
*******

*******
Oops
keyCode = 332
Widget = dateBooked
*******

I was entering numeric data, and as I do a lot of data entry at work, by 
default I use the numeric keypad, so I guess I just found that extended 
ASCII stuff. Is there a easy way around this with chr()?

Or is it a case of making my own keycode to character dictionary? I'm 
feeling lazy at the moment.

Regards, 


Liam Clarke

-- 
'There is only one basic human right, and that is to do as you damn well 
please.
And with it comes the only basic human duty, to take the consequences.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050410/a1e89358/attachment.htm


More information about the Tutor mailing list