Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
575 views
in Technique[技术] by (71.8m points)

python 3.x - Tkinter keybinding for Control-Shift-Tab

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

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

'<Control-ISO_Left_Tab>'.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...