[Tkinter-discuss] Tkinter and Alt bindings
bryan.oakley at gmail.com
Wed Feb 8 15:50:02 CET 2012
On Wed, Feb 8, 2012 at 4:56 AM, Michael Lange <klappnase at web.de> wrote:
> I cannot reproduce this here (debian squeeze with IceWM) either, the
> return "break" isn't even necessary.
I don't know why the original poster reports that the bindings
sometimes fire. My guess is that it's related to keyboard focus --
maybe the window doesn't have focus when the user thinks it does, so
the event never goes to the application. However, I can say for
certain why "break" is unnecessary and why the letter "s" is inserted
when they press alt-s.
In the original code the user is binding alt-s to the root window.
Such bindings are at the end of the bindtags for a given window. Thus,
the class bindings (where the insert actually happens) fire _before_
the root window bindings. Thus, the character gets inserted, _and
then_ the root binding fires. Returning "break" is useless at this
point because the character has already been inserted into the widget.
More information about the Tkinter-discuss