Shu*_*ule 2 tkinter key-bindings event-handling python-3.x
Control-Shift-Tab的键绑定是什么?我尝试过很多东西,似乎没什么用.我已经知道了tkinter.ttk.Notebook.enable_traversal.
如果你知道激活标签的处理程序,那也就足够了.
小智 6
表示事件的一般格式是:<[event modifier(s) - ] ... event type [-event detail]>.对于键绑定Ctrl + Shift + Tab,格式为:'Control-Shift-KeyPress-Tab'.在这种情况下,事件修饰符将是:Control- Shift-,事件类型:Keypress,以及事件详细信息:-Tab
以下代码(在python 2.7.6中)应该清楚:
from Tkinter import *
def key(event=None):
print 'You pressed Ctrl+Shift+Tab'
root = Tk()
frame = Frame(root, width=100, height=100)
frame.focus_set()
frame.bind('<Control-Shift-KeyPress-Tab>', key)
frame.pack()
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
编辑:以上适用于Windows和Mac.对于Linux,请使用
'<Control-ISO_Left_Tab>'.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2062 次 |
| 最近记录: |