1
我有打印的文字写入提示这个Python代码:的Tkinter绑定功能
from Tkinter import *
class CommandList(object):
show = False
def __init__(self):
self.show = False
def show(self):
print "showed"
def hide(self):
self.show = False
def is_showed(self):
return self.show
master = Tk()
tab = CommandList()
e = Entry(master, width=1000)
e.pack()
def enter(event):
master.quit()
def escape(event):
exit()
def tabulator(tab):
print type(tab)
tab.show()
e.bind('<Control_L>j', enter)
e.bind('<Return>', enter)
e.bind('<Escape>', escape)
e.bind('<Tab>', lambda event, tab=tab: tabulator(tab))
e.focus_set()
master.mainloop()
print e.get()
它工作正常,但 当我按下Tab键,所以我得到的错误:
<class '__main__.CommandList'>
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1535, in __call__
return self.func(*args)
File "stack-question.py", line 41, in <lambda>
e.bind('<Tab>', lambda event, tab=tab: tabulator(tab))
File "stack-question.py", line 34, in tabulator
tab.show()
TypeError: 'bool' object is not callable
我看到该选项卡类型CommandList,所以为什么我得到“TypeError:'bool'对象不可调用?”?
非常感谢。我忽略了这个愚蠢的错误... – LegnaRuoy