[Tkinter-discuss] Tkinter and Alt bindings

Michael Lange klappnase at web.de
Thu Feb 9 21:04:31 CET 2012


Hi,

Thus spoketh Bryan Oakley <bryan.oakley at gmail.com> 
unto us on Thu, 9 Feb 2012 08:58:25 -0600:

> On Thursday, February 9, 2012, Russell Adams <RLAdams at adamsinfoserv.com>
> wrote:
> > On Thu, Feb 09, 2012 at 11:22:47AM +0100, Michael Lange wrote:
> >> Hi,
> >>
> >> ##########
> >> entry .e
> >> grid .e -column 0 -row 0
> >> bind . <Alt-s> {puts "Alt-s pressed"}
> >> focus .e
> >> #########
> >>
> >> If you store this as test.tcl and then run it with $ wish test.tcl ,
> >> is
> it
> >> the same as in your Python example?
> >
> > Yes, Alt-s does not work. If I change it to Mod1, that triggers but
> > still adds "s" to the entry widget.
> 
> Just to reiterate so there's no confusion: the "s" being inserted is a
> feature, not a bug. I explained why in an earlier message and on
> stackoverflow. It has to do with the default ordering of bind tags.

now I am getting confused ;)
When I run the above example (or the one by the OP) and press Alt-s,
nothing is inserted in the entry, and that is just what I would expect
as of the widget's default bindings, or am I missing something here?

The default bindings are defined in entry.tcl, the relevant part looks
like:

  # Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
  # Otherwise, if a widget binding for one of these is defined, the
  # <KeyPress> class binding will also fire and insert the character,
  # which is wrong.  Ditto for Escape, Return, and Tab.

  bind Entry <Alt-KeyPress> {# nothing}

Now, when I comment out the above line and run the examples, the "s" is
actually inserted in the entry. Russell, is it possible that you miss
entry.tcl or that it is somehow broken? This would explain why the "s"
is inserted when Mod1 is used - but unfortunately not why Alt is not
working  :(
I still suspect the WM...   ;)

Regards

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Immortality consists largely of boredom.
		-- Zefrem Cochrane, "Metamorphosis", stardate 3219.8


More information about the Tkinter-discuss mailing list