####BELOW is my python code. I have to use GUI interfface you enter a property v
ID: 3780107 • Letter: #
Question
####BELOW is my python code. I have to use GUI interfface you enter a property value and it is supposed to display assesment value and property tax. IT dispalsy the assesment value but it doesn't display my property tax. What am I doing wrong? can someone explain to me the change I need to make in my code? Thanks in advance. import tkinter class PropertyTaxGUI: def __init__(self): self.main_window = tkinter.Tk() self.top_frame = tkinter.Frame() self.mid_frame = tkinter.Frame() self.third_frame = tkinter.Frame() self.bottom_frame = tkinter.Frame() self.prompt_label = tkinter.Label(self.top_frame, text='Enter the property value: $') self.property_entry = tkinter.Entry(self.top_frame, width=10) self.prompt_label.pack(side='left') self.property_entry.pack(side ='right') self.calc_button = tkinter.Button(self.bottom_frame, text = 'Calculate', command = self.calculate) self.quit_button = tkinter.Button(self.bottom_frame, text = 'Quit', command = self.main_window.destroy) self.value = tkinter.StringVar() self.calc_button.pack(side='right') self.quit_button.pack(side='right') self.assess_label= tkinter.Label(self.mid_frame, text='Assessment Value: ') self.assess_label.pack(side='left') self.value_label = tkinter.Label(self.mid_frame, textvariable=self.value) self.value_label.pack(side='right') self.prop_label= tkinter.Label(self.third_frame, text='Property Tax: ') self.prop_label.pack(side='left') self.propTax_label = tkinter.Label(self.mid_frame, textvariable=self.value) self.propTax_label.pack(side='right') self.top_frame.pack() self.mid_frame.pack() self.third_frame.pack() self.bottom_frame.pack() tkinter.mainloop() def calculate(self): propVal = float(self.property_entry.get()) assessVal = str(format(float(((.6)*propVal)), '.2f')) self.value.set(assessVal) def taxCalculate(self): propVal = float(self.property_entry.get()) assessVal = str(format(float(((.6)*propVal)), '.2f')) assessTax = str(format(float(((.64)*assessVal)), '.2f')) self.value.set(assessTax) my_gui = PropertyTaxGUI()
Explanation / Answer
import tkinter class PropertyTaxGUI: def __init__(self): self.main_window = tkinter.Tk() self.top_frame = tkinter.Frame() self.mid_frame = tkinter.Frame() self.third_frame = tkinter.Frame() self.bottom_frame = tkinter.Frame() self.prompt_label = tkinter.Label(self.top_frame, text='Enter the property value: $') self.property_entry = tkinter.Entry(self.top_frame, width=10) self.prompt_label.pack(side='left') self.property_entry.pack(side ='right') self.calc_button = tkinter.Button(self.bottom_frame,text = 'Calculate', command = self.calculate) self.quit_button = tkinter.Button(self.bottom_frame, text = 'Quit',command = self.main_window.destroy) self.value = tkinter.StringVar() self.calc_button.pack(side='right') self.quit_button.pack(side='right') self.assess_label= tkinter.Label(self.mid_frame, text='Assessment Value: ') self.assess_label.pack(side='left') self.calculate() # this sets 'self.value' to be assessment value self.value_label = tkinter.Label(self.mid_frame, textvariable=self.value) self.value_label.pack(side='right') self.prop_label= tkinter.Label(self.third_frame, text='Property Tax: ') self.prop_label.pack(side='left') self.taxCalculate() # this sets 'self.value' to be 'Property tax' self.propTax_label = tkinter.Label(self.mid_frame, textvariable=self.value) self.propTax_label.pack(side='right') self.top_frame.pack() self.mid_frame.pack() self.third_frame.pack() self.bottom_frame.pack() tkinter.mainloop() def calculate(self): propVal = float(self.property_entry.get()) assessVal = str(format(float(((.6)*propVal)), '.2f')) self.value.set(assessVal) def taxCalculate(self): propVal = float(self.property_entry.get()) assessVal = str(format(float(((.6)*propVal)), '.2f')) assessTax = str(format(float(((.64)*assessVal)), '.2f')) self.value.set(assessTax) my_gui = PropertyTaxGUI()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.