import tkinter
top=tkinter.Tk()
t=tkinter.Text(top,height=1,width=1,bd=2,font=10)
t.grid(row=0,column=0)
b1=tkinter.Button(top,height=2,width=8,bd=2,text="MC",fg="Red")
b1.grid(row=1,column=1)
b2=tkinter.Button(top,height=2,width=8,bd=2,text="Backspace",fg="Red")
b2.grid(row=1,column=2)
b3=tkinter.Button(top,height=2,width=8,bd=2,text="CE",fg="Red")
b3.grid(row=1,column=3)
b4=tkinter.Button(top,height=2,width=8,bd=2,text="C",fg="Red")
b4.grid(row=1,column=4)
b5=tkinter.Button(top,height=2,width=8,bd=2,text="MR",fg="Red")
b5.grid(row=2,column=1)
b6=tkinter.Button(top,height=2,width=8,bd=2,text="7",fg="Blue")
b6.grid(row=2,column=2)
b7=tkinter.Button(top,height=2,width=8,bd=2,text="8",fg="Blue")
b7.grid(row=2,column=3)
b8=tkinter.Button(top,height=2,width=8,bd=2,text="9",fg="Blue")
b8.grid(row=2,column=4)
b9=tkinter.Button(top,height=2,width=8,bd=2,text="/",fg="Red")
b9.grid(row=2,column=5)
b10=tkinter.Button(top,height=2,width=8,bd=2,text="sqrt",fg="Blue")
b10.grid(row=2,column=6)
b11=tkinter.Button(top,height=2,width=8,bd=2,text="MS",fg="Red")
b11.grid(row=3,column=1)
b12=tkinter.Button(top,height=2,width=8,bd=2,text="4",fg="Blue")
b12.grid(row=3,column=2)
b13=tkinter.Button(top,height=2,width=8,bd=2,text="5",fg="Blue")
b13.grid(row=3,column=3)
b14=tkinter.Button(top,height=2,width=8,bd=2,text="6",fg="Blue")
b14.grid(row=3,column=4)
b15=tkinter.Button(top,height=2,width=8,bd=2,text="*",fg="Red")
b15.grid(row=3,column=5)
b16=tkinter.Button(top,height=2,width=8,bd=2,text="%",fg="Blue")
b16.grid(row=3,column=6)
b17=tkinter.Button(top,height=2,width=8,bd=2,text="M+",fg="Red")
b17.grid(row=4,column=1)
b18=tkinter.Button(top,height=2,width=8,bd=2,text="1",fg="Blue")
b18.grid(row=4,column=2)
b19=tkinter.Button(top,height=2,width=8,bd=2,text="2",fg="Blue")
b19.grid(row=4,column=3)
b20=tkinter.Button(top,height=2,width=8,bd=2,text="3",fg="Blue")
b20.grid(row=4,column=4)
b21=tkinter.Button(top,height=2,width=8,bd=2,text="-",fg="Red")
b21.grid(row=4,column=5)
b22=tkinter.Button(top,height=2,width=8,bd=2,text="1/x",fg="Blue")
b22.grid(row=4,column=6)
b23=tkinter.Button(top,height=2,width=8,bd=2,text="M-",fg="Red")
b23.grid(row=5,column=1)
b24=tkinter.Button(top,height=2,width=8,bd=2,text="0",fg="Blue")
b24.grid(row=5,column=2)
b25=tkinter.Button(top,height=2,width=8,bd=2,text="+/-",fg="Blue")
b25.grid(row=5,column=3)
b26=tkinter.Button(top,height=2,width=8,bd=2,text=".",fg="Blue")
b26.grid(row=5,column=4)
b27=tkinter.Button(top,height=2,width=8,bd=2,text="+",fg="Red")
b27.grid(row=5,column=5)
b28=tkinter.Button(top,height=2,width=8,bd=2,text="=",fg="Red")
b28.grid(row=5,column=6)
def Addition(x,y):
    return x+y
b27.bind("<Button>",Addition)

def Subtraction(x,y):
    return x-y
b21.bind("<Button>",Subtraction)

def Multiplication(x,y):
    return x*y
b15.bind("<Button>",Multiplication)

def Division(x,y):
    return x/y
b9.bind("<Button>",Division)

def Inverse(x):
    return 1/x
b22.bind("<Button>",Inverse)

def SquareRoot(x):
    return x**0.5
b10.bind("<Button>",SquareRoot)

def Clear():
    delete[0,END]
b4.bind("<Button>",Clear)
top.geometry("350x180")
top.mainloop()

Click Here

Can anyone help me with my calculator? i have made some functions and some are remaining. i don't know how to make use of "equal to or =" button. and also the arrangement.Thanks in advance.

Edited 1 Year Ago by johnny blaz97

This question has already been answered. Start a new discussion instead.