我有一个带有此脚本的按钮
b1 = Button(root,
text="1",
width=10,
command=lambda:add("1","1")
)
添加功能如下:
def add(symbols,real):
with open("equation.txt","r") as f:
equationreal = f.read()
with open("show.txt","r") as f:
equation = f.read()
out.insert(END,real)
equationreal += symbols
equation += real
with open("equation.txt","w") as f:
f.write(equationreal)
with open("show.txt","w") as f:
f.write(equation)
print(equationreal)
每次我按b1按钮时,都会引发此错误:
command = lambda:add(“ 1”,“ 1”)
TypeError:“按钮”对象不可调用
我尝试了许多不同的方法,甚至制作了一个调用add(“ 1”,“ 1”)的函数。每当我认为我有导致这种情况中断的线路时,它都会改变。有帮助吗?