Discussion:
Tkinter Return/Enter key handling
(too old to reply)
Bob Greschke
2005-05-18 23:33:00 UTC
Permalink
I have a Tkinter Text() widget in a program that the user can type stuff
into. Most of our keyboards have the regular keys with a "Return" key, and
a numeric keypad with an "Enter" key. The Return key generates events with
"<Return>" for the keysym, and the Enter key generates events with
"<KP_Enter>" as the keysym. The Text() widget does a carriage
return/linefeed when the Return key is pressed, but does nothing when the
Enter key is pressed. So I did a

Text.bind("<KP_Enter", Return)

with a suitable

def Return(e):
TheText.insert(END, linesep)

But isn't there a way to handle this with some sort of keyboard remapping
thingy?? I'm right on the edge of understanding half of what I read about
Tkinter. :)

Thanks!

Bob
phil
2005-05-19 01:27:29 UTC
Permalink
If you are talking Linux there's .Xdefaults
Which I had to resort to for tn5250.
For Tkinter apps its a LOT easier to just use bind.

Win32? dunno.
Post by Bob Greschke
I have a Tkinter Text() widget in a program that the user can type stuff
into. Most of our keyboards have the regular keys with a "Return" key, and
a numeric keypad with an "Enter" key. The Return key generates events with
"<Return>" for the keysym, and the Enter key generates events with
"<KP_Enter>" as the keysym. The Text() widget does a carriage
return/linefeed when the Return key is pressed, but does nothing when the
Enter key is pressed. So I did a
Text.bind("<KP_Enter", Return)
with a suitable
TheText.insert(END, linesep)
But isn't there a way to handle this with some sort of keyboard remapping
thingy?? I'm right on the edge of understanding half of what I read about
Tkinter. :)
Thanks!
Bob
Bob Greschke
2005-05-19 02:36:09 UTC
Permalink
Sorry. Yeah, Linux. Eww. Ick. Don't want to mess with .Xdefaults. It
works, so I guess I'll just keep the .bind. Thanks, Phil!
Post by phil
If you are talking Linux there's .Xdefaults
Which I had to resort to for tn5250.
For Tkinter apps its a LOT easier to just use bind.
Win32? dunno.
Loading...