在Python Tkinter中绑定Ctrl(-)
我有一个带有文本小部件的应用程序,当用户按下控制键和减号键(-)时,我希望我的字体变小 代码在Python Tkinter中绑定Ctrl(-),python,tkinter,Python,Tkinter,我有一个带有文本小部件的应用程序,当用户按下控制键和减号键(-)时,我希望我的字体变小 代码 self.bind_all("<Control-=>", self.increaseFont) self.bind\u all(“,self.increaseFont) 当用户按下control键和equals键时,似乎可以很好地增加字体,但是行 self.bind_all("<Control-->", self.decreaseFont) self.bind\u all(
self.bind_all("<Control-=>", self.increaseFont)
self.bind\u all(“,self.increaseFont)
当用户按下control键和equals键时,似乎可以很好地增加字体,但是行
self.bind_all("<Control-->", self.decreaseFont)
self.bind\u all(“,self.decreaseFont)
似乎不起作用
当我尝试运行它时,它会给我一个运行时错误:
Traceback (most recent call last):
File "./mathEditor.py", line 122, in <module>
app = MathEditor(fileName = sys.argv[1])
File "./mathEditor.py", line 40, in __init__
self.bind_all("<Control-->", self.decreaseFont)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 997, in bind_all
return self._bind(('bind', 'all'), sequence, func, add, 0)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 940, in _bind
self.tk.call(what + (sequence, cmd))
_tkinter.TclError: no event type or button # or keysym
回溯(最近一次呼叫最后一次):
文件“/mathEditor.py”,第122行,在
app=MathEditor(文件名=sys.argv[1])
文件“/mathEditor.py”,第40行,在__
self.bind\u all(“,self.decreaseFont)
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py”,第997行,全部绑定
返回self.\u bind(('bind','all'),sequence,func,add,0)
文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py”,第940行,在_-bind中
self.tk.call(what+(sequence,cmd))
_tkinter.TclError:没有事件类型、按钮或keysym
试试self.bind\u all(“,self.decreaseFont)