Tkinter Return/Enter key handling

B

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

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
 
P

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.
 
B

Bob Greschke

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top