Validating Entry in tkinter

Wolfgang Meiners WolfgangMeiners01 at web.de
Mon Jul 25 04:48:12 EDT 2011


Am 25.07.11 02:11, schrieb Saul Spatz:
> 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? 

Hi,
i think you can find the answer using the following link:
http://stackoverflow.com/questions/4140437/python-tkinter-interactively-validating-entry-widget-content

Wolfgang



More information about the Python-list mailing list