Validating Entry in tkinter
saul.spatz at gmail.com
Mon Jul 25 13:46:36 CEST 2011
Thanks so much, this is great. I want to validate that the user is entering a string appropriate for bytes.fromhex. Here's how I modified your validate funtion:
def validate(before, after):
print(before, "-->", after)
return after[-1] in '1234567890abcdefABCDEF '
I also had to change validate="all" to validate="key" in the Entry construction, since otherwise, I go an IndexError when the widget gets the focus. (try...except also worked, but I only care about keystrokes.)
I didn't know about the register method; that's the key.
More information about the Python-list