我正在开发一个应用程序来计算税务计算的计算基数(v_result.set和v_result2.set)。我想在vúresult3.set中同时添加这两个,但它给出了错误。见下文:
File "C:\Users\TESTES\Desktop\teeeeeeeeeeeeeeee.py", line 30, in calc
v_result3.set(float(v_result + v_result2))
TypeError: unsupported operand type(s) for +: 'DoubleVar' and 'DoubleVar'
请遵循以下完整代码:
from tkinter import *
root = Tk()
root.geometry('350x350')
l_label = Label(root, text='Receita 1')
l_label.place(x=10, y=10)
e_entry = Entry(root)
e_entry.place(x=100, y=10)
l_label2 = Label(root, text='Receita 2')
l_label2.place(x=10, y=40)
e_entry2 = Entry(root)
e_entry2.place(x=100, y=40)
# ---
v_result = DoubleVar()
l_rst = Label(root, textvariable=v_result)
l_rst.place(x=10, y=100)
v_result2 = DoubleVar()
l_rst2 = Label(root, textvariable=v_result2)
l_rst2.place(x=10, y=140)
v_result3 = DoubleVar()
l_rst3 = Label(root, textvariable=v_result3)
l_rst3.place(x=10, y=220)
def calc():
v_result.set(float(e_entry.get()) * 10 / 100)
v_result2.set(float(e_entry2.get()) * 10 / 100)
v_result3.set(float(v_result + v_result2))
bt = Button(root, text='Calc', command=calc)
bt.place(x=10, y=180)
root.mainloop()
你能帮帮我吗?