Validating Entry in tkinter

Saul Spatz saul.spatz at
Mon Jul 25 02:11:25 CEST 2011

In tcl/tk an Entry widget can be set to validate its contents with the validate option.  You have to give it a validatecommand (vcmd), which is a tcl script that runs when some action triggers validation.  Usually, the script would use "percent substitutions" so the script would be something like {ValidInt %P} where %P is the value of the widget should the proposed change occur.  

Can one do something like this in tkinter?  I've verified that with

e = Entry(master, validate = 'all', vcmd = validInt) 

the validInt function is called, but it isn't passed any parameters. I can't find that e has any attribute corresponding to the %P value above.

Is it not possible to do this in tkinter, or have I overlooked something? 

More information about the Python-list mailing list