I'm getting this error in tkinter: TypeError: 'Button' object is not callable

I'm getting this error in tkinter: TypeError: 'Button' object is not callable

我正在为我的计算器开发 GUI,但我 运行 遇到了错误。 在我发布在我的 GUI 项目上的最后几个问题中,我收到了非常有用的答案。所以我要感谢所有帮助过我的人。 然而这一次,我 运行 陷入了另一个错误。 我见过几个类似的问题,最接近我的问题的是这个... 我尝试了给出的解决方案,但它给我带来了同样的错误。如果这个问题与 SO 上的另一个问题重复,我深表歉意。

错误 TypeError: 'Button' object is not callable 我在 GUI 中单击清除按钮时出现此错误。

这是我的代码...

                                 import tkinter as Tk
                                 from tkinter import *
                                 root_var = Tk()
                                 root_var.title("Calculator")

                                 e = Entry(root_var, width=25, borderwidth=5)
                                 e.grid(row=0, column=0, columnspan=3, padx=10, pady=10)

                                 def button_click(number=None):

                                 #e.delete(0, END)
                                 current = e.get()
                                 e.delete(0, END)
                                 e.insert(0, str(current) + str(number) )

                                 def button_clear():
                                 e.delete(0, END)

     button_1 = Button(root_var, text="1", padx=50, pady=10, command=lambda: button_click(1))
     button_2 = Button(root_var, text="2", padx=50, pady=10, command=lambda: button_click(2))
     button_3 = Button(root_var, text="3", padx=50, pady=10, command=lambda: button_click(3))
     button_4 = Button(root_var, text="4", padx=50, pady=10, command=lambda: button_click(4))
     button_5 = Button(root_var, text="5", padx=50, pady=10, command=lambda: button_click(5))
     button_6 = Button(root_var, text="6", padx=50, pady=10, command=lambda: button_click(6))
     button_7 = Button(root_var, text="7", padx=50, pady=10, command=lambda: button_click(7))
     button_8 = Button(root_var, text="8", padx=50, pady=10, command=lambda: button_click(8))
     button_9 = Button(root_var, text="9", padx=50, pady=10, command=lambda: button_click(9))
     button_0 = Button(root_var, text="0", padx=50, pady=10, command=lambda: button_click(0))

button_addition = Button(root_var, text="+", padx=50, pady=10, command=lambda: button_click())
button_subtraction = Button(root_var, text="-", padx=50, pady=10, command=lambda: 
button_click())
button_multiplication = Button(root_var, text="*", padx=50, pady=10, command=lambda: 
button_click())
button_division = Button(root_var, text="/", padx=50, pady=10, command=lambda: button_click())
button_exponents = Button(root_var, text="^", padx=50, pady=10, command=lambda: 
button_click())

button_equals = Button(root_var, text="=", padx=50, pady=10, command=lambda: button_click())

button_clear = Button(root_var, text="C", padx=50, pady=10, command=lambda: button_clear())

button_1.grid(row=3, column=2)
button_2.grid(row=3, column=1)
button_3.grid(row=3, column=0)

button_4.grid(row=2, column=2)
button_5.grid(row=2, column=1)
button_6.grid(row=2, column=0)

button_7.grid(row=1, column=2)
button_8.grid(row=1, column=1)
button_9.grid(row=1, column=0)

button_0.grid(row=4, column=0)
button_addition.grid(row=4, column=1)
button_subtraction.grid(row=4, column=2)

button_multiplication.grid(row=5, column=0)
button_division.grid(row=5, column=1)
button_exponents.grid(row=5, column=2)

button_equals.grid(row=6, column=0)
button_clear.grid(row=6, column=1)
root_var.mainloop()

请帮帮我。谢谢!

您的程序的相同函数名称和变量名称不起作用

#corrected
import tkinter as Tk
from tkinter import *
root_var = Tk()
root_var.title("Calculator")

e = Entry(root_var, width=25, borderwidth=5)
e.grid(row=0, column=0, columnspan=3, padx=10, pady=10)

def button_click(number=None):

 #e.delete(0, END)
    current = e.get()
    e.delete(0, END)
    e.insert(0, str(current) + str(number) )

def clear():
    e.delete(0, END)

button_1 = Button(root_var, text="1", padx=50, pady=10, command=lambda: button_click(1))
button_2 = Button(root_var, text="2", padx=50, pady=10, command=lambda: button_click(2))
button_3 = Button(root_var, text="3", padx=50, pady=10, command=lambda: button_click(3))
button_4 = Button(root_var, text="4", padx=50, pady=10, command=lambda: button_click(4))
button_5 = Button(root_var, text="5", padx=50, pady=10, command=lambda: button_click(5))
button_6 = Button(root_var, text="6", padx=50, pady=10, command=lambda: button_click(6))
button_7 = Button(root_var, text="7", padx=50, pady=10, command=lambda: button_click(7))
button_8 = Button(root_var, text="8", padx=50, pady=10, command=lambda: button_click(8))
button_9 = Button(root_var, text="9", padx=50, pady=10, command=lambda: button_click(9))
button_0 = Button(root_var, text="0", padx=50, pady=10, command=lambda: button_click(0))

button_addition = Button(root_var, text="+", padx=50, pady=10, command=lambda: button_click())
button_subtraction = Button(root_var, text="-", padx=50, pady=10, command=lambda: 
button_click())
button_multiplication = Button(root_var, text="*", padx=50, pady=10, command=lambda: 
button_click())
button_division = Button(root_var, text="/", padx=50, pady=10, command=lambda: button_click())
button_exponents = Button(root_var, text="^", padx=50, pady=10, command=lambda: 
button_click())

button_equals = Button(root_var, text="=", padx=50, pady=10, command=lambda: button_click())

button_clear = Button(root_var, text="C", padx=50, pady=10, command=lambda: clear())

button_1.grid(row=3, column=2)
button_2.grid(row=3, column=1)
button_3.grid(row=3, column=0)

button_4.grid(row=2, column=2)
button_5.grid(row=2, column=1)
button_6.grid(row=2, column=0)

button_7.grid(row=1, column=2)
button_8.grid(row=1, column=1)
button_9.grid(row=1, column=0)

button_0.grid(row=4, column=0)
button_addition.grid(row=4, column=1)
button_subtraction.grid(row=4, column=2)

button_multiplication.grid(row=5, column=0)
button_division.grid(row=5, column=1)
button_exponents.grid(row=5, column=2)

button_equals.grid(row=6, column=0)
button_clear.grid(row=6, column=1)
root_var.mainloop()