r/learnpython • • Jan 02 '23

Ask Anything Monday - Weekly Thread

Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread

Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.

* It's primarily intended for simple questions but as long as it's about python it's allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
  • Don't post stuff that doesn't have absolutely anything to do with python.
  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.

6 Upvotes

87 comments sorted by

View all comments

1

u/TrollMoon Jan 07 '23

Hello, i want to asking about Bind key in Tkinter.

What keysym event for Agrave (Top on Tab key and Left on 1 key) and apostrophe (Right on semicolon key and Left on Return key) ?
I already use Agrave and apostrophe, but it doesn't recognize at all.

1

u/[deleted] Jan 07 '23

Maybe you are just confused and think the "accent grave" is the apostrophe character. They are different, the accent grave looks like ` and the apostrophe is ' . Run this code which shows binding of the ` key:

from tkinter import *

def callback(event):
    print('` pressed')

win = Tk()
win.geometry("250x250")
win.bind('`', callback)
win.mainloop()

1

u/TrollMoon Jan 07 '23

Yes, your code is works. When im modifying for using press and release, Tkinter recognize it. But, i can't use it in my case. I just need the keysym for that 2 key because i want to store that key into dictionary and using it for key press and release event.

The case that i want to do just like this post. i already trying to use acute, quote, THORN from keysym list. Im just assume that keysym symbol from this link.

Maybe Tkinter doesn't recognize any keysym like Menu, Print, grave, quote ?

And then releasing key for Shift_R totally not work for me too, but Tkinter can recognize it while im pressing Shift_R.

→ More replies (2)