小编Ray*_*Ray的帖子

Tkinter中的多个键事件绑定 - "Control + E""Command(apple)+ E"等

Mac OS X 10.6.6 - Tkinter

我想绑定多键事件,虽然我找到了一篇文章和Tk手册页,但我一直无法正常工作.我是新来的.

我的成功喜忧参半.我已经能够获得Shift +字母键,但不能获得Control或Command(Apple键).我真正想做的是Command + letter和Control +字母键,因此它理论上可以在Windows和OS X中使用.

我希望它在窗口级工作,所以我使用root.也许有更好的方法.以下是我尝试过的内容:

root.bind('<Shift-E>', self.pressedCmdE)   # Works
root.bind('e', self.pressedCmdE)           # Works
root.bind('<Command-E>', self.pressedCmdE) # Does Not Work
#root.bind('<Mod1-E>', self.pressedCmdE)   #   # Do Mod1, M1, and
#root.bind('<M1-E>', self.pressedCmdE)     #   # Command mean the same thing?
Run Code Online (Sandbox Code Playgroud)

奇怪的是,当我按alt/option +(E,N或其他)时,会产生错误.它是否与PythonLauncher交互?

2011-06-16 16:19:22.618 Python[1546:d07] An uncaught exception was raised
2011-06-16 16:19:22.621 Python[1546:d07] *** -[NSCFString characterAtIndex:]: Range or index out of bounds
2011-06-16 16:19:22.622 Python[1546:d07] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** …
Run Code Online (Sandbox Code Playgroud)

events binding command tkinter key

9
推荐指数
2
解决办法
1万
查看次数

标签 统计

binding ×1

command ×1

events ×1

key ×1

tkinter ×1