토지 양도세를 계산하는 tkinter 프로그램을 만들려고 합니다. 이 코드를 실행하면 계산하려고 하면 다음과 같은 오류가 발생합니다.
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'
내가 가진 코드는 다음과 같습니다.
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()
누군가 내 프로그램에 어떤 문제가 있는지 말해 줄 수 있나요?