Tkinter快捷键用于Control-Shift-Tab [英] Tkinter keybinding for Control-Shift-Tab

查看:531
本文介绍了Tkinter快捷键用于Control-Shift-Tab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Control-Shift-Tab的键绑定是什么?我已经尝试了很多东西,但似乎没有任何效果.我已经知道tkinter.ttk.Notebook.enable_traversal.

What's the key-binding for Control-Shift-Tab? I've tried lots of things and nothing seems to work. I'm already aware of tkinter.ttk.Notebook.enable_traversal.

如果您知道用于标签激活的处理程序,那也足够了.

If you know of a handler for tabs being activated, that would suffice, too.

推荐答案

代表事件的一般格式为: < [事件修饰符-] ...事件类型[-事件详细信息]>. 对于键绑定Ctrl + Shift + Tab,格式为: 'Control-Shift-KeyPress-Tab'. 在这种情况下,事件修饰符为: 控制- 转移-, 事件类型: 按键, 和事件详细信息: -Tab

The general format for representing an event is: <[event modifier(s)-]...event type [-event detail]>. For key-binding Ctrl+Shift+Tab the format would be: 'Control-Shift-KeyPress-Tab'. In this case the event modifiers would be: Control- Shift-, the event type: Keypress, and the event detail: -Tab

下面的代码(在python 2.7.6中)应该很清楚:

The following code (in python 2.7.6) should make it clear:

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()

上面的方法适用于Windows和Mac.对于Linux,使用

The above works well for Windows and Mac. For Linux, use

'<Control-ISO_Left_Tab>'.

这篇关于Tkinter快捷键用于Control-Shift-Tab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆