我有一个python代码,它将文本写入提示符:
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键时,出现错误:
^{pr2}$我看到标签是类型CommandList,所以为什么我得到“TypeError:'bool'object is not callable?”??在
在您的
CommandList
类的第一行中,您将show
定义为等于False的bool,然后无论如何都没有使用它。现在,当您有一个CommandList
对象时,show()
尝试调用您定义的类级bool,而不是方法。在相关问题 更多 >
编程相关推荐