How to bind Ctrl+/ in python tkinter?

前端 未结 2 1662
灰色年华
灰色年华 2020-12-08 16:26


works but


doesn\'t.

I am unab

相关标签:
2条回答
  • 2020-12-08 16:59

    Use <Control-slash>:

    def quit(event):
        print "you pressed control-forwardslash"
        root.quit()
    
    root = tk.Tk()
    root.bind('<Control-slash>', quit)      # forward-slash
    # root.bind('<Control-backslash>', 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                 |
    
    0 讨论(0)
  • 2020-12-08 17:10

    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 <Win_L> and <Win_R>.

    0 讨论(0)
提交回复
热议问题