# Fixed Calculator

unknown
python
3 years ago
2.3 kB
5
Indexable
Never
```from tkinter import *
window=Tk()
lbl=Label(window, text="Welcome to maths help project.",fg="blue", font=('arial',14,'bold'))
lbl.place(x=130, y=120)
lbl2=Label(window, text ="This project is for making two digit calculations.")
lbl2.place(x=130, y=160)
lbl3=Label(window, text="Give values of a and b below to get the solution.")
lbl3.place(x= 130, y= 200)
txtfld=Entry(window, bg="yellow", fg="green", font=("arial",12,"bold"))
txtfld.place(x=200, y=250)
txtfld2=Entry(window, bg="yellow", fg="green", font=("arial",12,"bold"))
txtfld2.place(x=200, y=280)

a = int(txtfld.get())
b = int(txtfld2.get())
global result1
result1 = Label(window, text=a+b, bg="yellow", fg="blue",font=("arial",16,"bold"))
result1.place(x=50,y=380)
def subtract():
a = int(txtfld.get())
b = int(txtfld2.get())
global result2
result2 = Label(window, text=a-b, bg="yellow", fg="blue",font=("arial",16,"bold"))
result2.place(x=180,y=380)
def multiply():
a = int(txtfld.get())
b = int(txtfld2.get())
global result3
result3 = Label(window, text=a*b, bg="yellow",fg="blue",font=("arial",16,"bold"))
result3.place(x=310,y=380)
def divide():
a = int(txtfld.get())
b = int(txtfld2.get())
global result4
result4 = Label(window, text=a/b, bg="yellow",fg="blue",font=("arial",16,"bold"))
result4.place(x=440,y=380)
def reset_game():
txtfld.delete(0, END)
txtfld2.delete(0, END)
result1['text'] = ""
result2['text'] = ""
result3['text'] = ""
result4['text'] = ""

button1.place(x=50, y=330)
button2=Button(window, command=subtract, text='subtract', bg="gold", fg="red", font=("arial",12,"bold"))
button2.place(x=150, y=330)
button3=Button(window, command=multiply, text='multiply', bg="gold", fg="red", font=("arial",12,"bold"))
button3.place(x=280, y=330)
button4=Button(window, command=divide, text='divide', bg="gold", fg="red", font=("arial",12,"bold"))
button4.place(x=400, y=330)
button5=Button(window,command=reset_game, text="restart game", bg="blue", font=("arial",14,"bold"))
button5.place(x=220, y=450)
window.title('Calculator')
window.geometry("550x580+20+20")
window.mainloop()

```