Estoy intentando hacer un programa tkinter que calcule el impuesto a la transferencia de tierras. Cuando ejecuto este código, me da el siguiente error cuando intento calcularlo:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Angela\AppData\Local\Programs\Python\Python37- 32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:/Users/Angela/PycharmProjects/Editor/Editor.py", line 16, in <lambda>
ok = Button(master, text="Calculate tax", command= lambda: callback(master, entry_box)).grid(row=0, column=2)
File "C:/Users/Angela/PycharmProjects/Editor/Editor.py", line 19, in callback
price = entry_box.get()
AttributeError: 'NoneType' object has no attribute 'get'
Aquí está el código que tengo:
master = Tk()
label = Label(master, text="Price of house: ").grid(row=0)
entry_box = Entry(master).grid(row=0, column=1)
ok = Button(master, text="Calculate tax", command= lambda: callback(master, entry_box)).grid(row=0, column=2)
def callback(master, entry_box):
price = entry_box.get()
price = int(price)
tax_price = 275
if price > 55000:
tax_price += (250000 - 55000) * 0.1
else:
tax_price += 55000 * 0.05
if price > 250000:
tax_price += (368333 - 250000) * 0.15
if price > 368333:
tax_price += (400000 - 368333) * 0.15
if price > 400000:
tax_price += (2000000 - 400000) * 0.2
if price > 2000000:
tax_price += (price - 2000000) * 0.25
show_tax_price = Label(master, text=tax_price).grid(row=0, column=3)
mainloop()
¿Alguien puede decirme qué está mal con mi programa?