나는 gui에 나타나기 위해 모든 것을 얻었지만 지금은 세금 환급을 올바르게받을 수 없습니다.파이썬 Tkinter 재산세 GUI
여기 좀 더 살펴본 후 제 코드입니다. 이제 각 레이블에 대해 두 개의 문자열 객체를 만들었습니다. 그러나 재산세를 부유세로 전환 할 수는 없습니다.
재산세는 평가 가치 $ 100마다 $ 0.75이어야합니다. 이 속성 값에 대한 250000을 입력한다면
따라서, 내가 당신이되어 무엇을해야하는지 생각 150000의 평가 값과 1125
import tkinter
def main():
my_gui = PropertyTaxGUI()
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()
#create widgets for the top frame
self.prompt_label = tkinter.Label(self.top_frame,
text='Enter the property value: $')
self.prop_value = tkinter.Entry(self.top_frame,
width=10)
#pack the top frame's widgets
self.prompt_label.pack(side='left')
self.prop_value.pack(side='left')
#create widgets for the middle frame
self.assess_val = tkinter.Label(self.mid_frame,
text='Assessment Value: $')
#need a stringvar object to associate with an output label
self.value = tkinter.StringVar()
#create a label and associate it with the stringvar object
self.assess_label = tkinter.Label(self.mid_frame,
textvariable=self.value)
#pack the middle frame's widgets
self.assess_val.pack(side='left')
self.assess_label.pack(side='left')
#create the widgets for the third frame
self.prop_tax = tkinter.Label(self.third_frame,
text='Property Tax: $')
#need a stringvar object to associate witih second output label
self.value2 = tkinter.StringVar()
#create a label and associate it with the stringvar object
self.prop_tax_val = tkinter.Label(self.third_frame,
textvariable=self.value2)
#pack the third frame's widgets
self.prop_tax.pack(side='left')
self.prop_tax_val.pack(side='left')
#create the button widgets for the bottom frame
self.calc_button = tkinter.Button(self.bottom_frame,
text='Calculate',
command=self.calc_button_event)
self.quit_button = tkinter.Button(self.bottom_frame,
text='Quit',
command=self.main_window.destroy)
#pack the buttons
self.calc_button.pack(side='left')
self.quit_button.pack(side='left')
#pack the frames
self.top_frame.pack()
self.mid_frame.pack()
self.third_frame.pack()
self.bottom_frame.pack()
#enter the tkinter main loop
tkinter.mainloop()
def calc_button_event(self):
self.calculate()
self.taxCalc()
def calculate(self):
propVal = float(self.prop_value.get())
assessVal = propVal*0.6
self.value.set(assessVal)
def taxCalc(self):
assessVal = float(self.value2.get())
assessTax = assessVal*0.0075
self.value2.set(assessTax)
main()
높이와 너비 차원으로 tkinter.Canvas()를 추가해야한다고 생각합니다. 지금 가지고있는 것은 유효하지만 캔버스에는 없습니다. – Ajax1234
나는 지금 편집하고 또 다른 문제를 생각해 냈습니다. 제 코드를 다시 보실래요? – Classicalclown
숙제 : 제목을 둥근 질문 문장으로 바꾸면 내 downvote가 위로 바뀝니다. – peterh