How to get Tkinter Mac-friendly menu shortcuts (cmd+key)

…衆ロ難τιáo~ 提交于 2019-11-29 14:23:47
martineau

I think you would need to specify one of the Meta and M Modifiers listed at Tk Built-in Commands -- perhaps Mod1 instead of Control. You might also find this list of keysyms recognized by Tk useful.

Although I've never actually every tried to do it -- if all else fails -- you might be able to determine what you need to know by writing your own event handler function def handlerName(event):, bind it to '<Any-KeyPress>' events, and then, in the function print the values of the attributes of the event argument being passed it when it's called -- such as event.keycode, event.keysym, event.keysym_num, etc -- thereby allowing you to see what to use for detecting ⌘-key modified keystrokes on your Mac.

Lastly, Python is open-source, so you can always try reading that.

Update: From the code in this answer it sounds like the Command- would work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!