[Tutor] Tkinter entry box text changed event

Alan Gauld alan.gauld at yahoo.co.uk
Mon Apr 10 04:28:49 EDT 2017


On 10/04/17 05:43, Phil wrote:

> I would like a function to be called when I enter text 
> and then tab to the next entry box.
One of the things about Entry boxes is that they are extremely
flexible and have many event types associated with them.
The consequence of this is that you as a programmer need
to be very, very specific in deciding which events you
want to bind to:

Enter text includes events such as key-press,
key-release. These catch individual keystrokes.

Then there are the navigation bindings such as focusIn
and FocusOut for entering and leaving the Entry(regardless
of whether you change anything.

And of course you have mouse events to consider too.

And you also have the StringVar() mechanism which auto
detects changed values and assigns them to the nominated
textvariable.

So do you want to trigger your code when keys are pressed?
or when the user leaves the box? or when the user arrives
in the next box? And do you only want to do this when the
user is tabbing around in sequence? Or what if they
randomly select one of the entry boxes using the mouse?
What if they use the mouse to select boxes rather than
the tab key?

Once you know that you will know which event types you
want to bind to. But 'StringVar()' is not one of them...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list