[Tkinter-discuss] StringVar() .trace(), .trace_vdelete() use

Bob Greschke bob at greschke.com
Thu Mar 7 04:11:39 CET 2013


I saw that earlier in the day (and a couple of weeks ago too).  I understand it just about as well as lambdas. :)  Do all of those values get passed each time a key is pressed?  Also, each Entry() field has a different max length.  Where do I pass that in all of this?  It would need to be an arg to vcmd in the Entry().  I couldn't see how to do that.  I have an old chunk of code that allows you to pass parameters to things like the functions associated with a Button widget's 'command=' callback, but I didn't see how that would fit in here.  I don't want to create a different vcmd for every possible allowed length. (there's dozens in the whole program).

On 2013-03-06, at 18:18, Bryan Oakley <bryan.oakley at gmail.com> wrote:

> If you're doing this for input validation you should consider using
> the built-in validation features of the entry widget instead of using
> a trace. Here's a description of how to use it:
> 
> http://stackoverflow.com/a/4140988/7432
> 
> 
> On Wed, Mar 6, 2013 at 6:49 PM, Bob Greschke <bob at passcal.nmt.edu> wrote:
>> Hi!
>> 
>> I'm messing with the .trace() function of StringVar()s to, in this case, check to see that the user has not entered more than an allowable number of characters (ckW() below does that).  I'm replacing a monstrous <KeyRelease> .bind method.
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
> 



More information about the Tkinter-discuss mailing list