I am coding an application that sends entries to a database. I use tkinter.Entry
for getting user input. When I press the function keys a weird question mark appears in the entry and python treats it as a character on my mac. While I used it on windows I didn't get the question marks. I also restarted my mac but it doesn't help.
CodePudding user response:
I found a workaround for it.
- Create a function that returns "break" when function keys are pressed.
def validate(event):
keys = ['F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12']
for i in keys:
if i == event.keysym:
return 'break'
- Now bind the entries to the validate function
sample_entry.bind('<KeyPress>', validate)
This skips the KeyPress
when the function keys are pressed.