How to bind Ctrl+/ in python tkinter?

匿名 (未验证) 提交于 2019-12-03 01:07:01

问题:

 

works but

doesn't.

I am unable to bind ctrl + / in python. Is there any documentation of all the possible keys?

回答1:

Use :

def quit(event):     print "you pressed control-forwardslash"     root.quit()  root = tk.Tk() root.bind('', quit)      # forward-slash # root.bind('', quit)  # backslash root.mainloop()

I don't have a link to a complete list of these event names. Here is a partial list I've collected:

| event                 | name                  | | Ctrl-c                | Control-c             | | Ctrl-/                | Control-slash         | | Ctrl-\                | Control-backslash     | | Ctrl+(Mouse Button-1) | Control-1             | | Ctrl-1                | Control-Key-1         | | Enter key             | Return                | |                       | Button-1              | |                       | ButtonRelease-1       | |                       | Home                  | |                       | Up, Down, Left, Right | |                       | Configure             | | window exposed        | Expose                | | mouse enters widget   | Enter                 | | mouse leaves widget   | Leave                 | |                       | Key                   | |                       | Tab                   | |                       | space                 | |                       | BackSpace             | |                       | KeyRelease-BackSpace  | | any key release       | KeyRelease            | | escape                | Escape                | |                       | F1                    | |                       | Alt-h                 |


回答2:

Here is a list of all the tk keysysm codes: https://www.tcl.tk/man/tcl8.6/TkCmd/keysyms.htm

The two I was looking for was and .



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