In the given example from this post, it was mentioned that if default bindtags are used then event value will not be visible inside definition (there will be lag by one).
When you do a binding on a widget, you aren't actually binding to a widget per se. When you do mywidget.bind(...)
, what is actually happening is that the binding is associated with a bind tag with the same name as the widget.
When an event is detected, Tkinter first figures out which widget intercepted the event. This widget will have a list of zero or more (by default: four) bind tags associated with it. Tkinter will check each tag in order to see if there's a binding that matches the event. If it finds one, it will execute the binding and then continue to the next tag, until it runs out of tags or one of the bound functions returns the string "break"
.
The sequence looks something like this:
"break"
then no more event processing is done. The "x" will not get inserted into the widget."break"
, tkinter proceeds to the next bind tag.Based on the ongoing discussion in the comment section, it appears this is still unclear. I'll try to make this as simple as possible:
It is the class binding which copies a character from the in-memory event object to the widget and thus causing it to appear on screen. Before the class binding fires, the character will not appear in the widget. After the class binding it will be in the widget.