'Change tk label text according to optionmenu
Im making a program that will do most of my homework. In compound interest, it gives a different answer than should. 5=P. R=2. 1=T The answer when compounded quarterly shoul be 0.100 but it gives answer 0.9 .... And also i want the formula for compound interest to change according to the text in drop which is an optionmenu. Thecode---
canvas1.create_window(200, 470, window=entry12)
entry23 = Entry (root)
canvas1.create_window(200, 530, window=entry23)
entry34 = Entry (root)
canvas1.create_window(200, 590, window=entry34)
menu=StringVar()
menu.set("Compounded")
drop=OptionMenu(root, menu, "Compounded annually", "Compounded half yearly", "Compounded quarterly")
drop.config(bg="black", fg="white")
canvas1.create_window(200, 650, window=drop)
def getvalue2():
p2=float(entry12.get())
r2=float(entry23.get())
t2=float(entry34.get())
rr=r2/2
tt=t2*2
rrrr=r2/4
tttt=t2*4
if drop=="Compounded half yearly":
duck=p2*(1+rr/100)**tt-p2
elif drop=="Compounded quarterly":
duck=p2*(1+rrrr/100)**tttt-p2
label=Label(root, text=float(duck))
solve=Button(text='Solve!', bg="red", command=getvalue2)
canvas1.create_window(200, 740, window=solve)```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|