from tkinter import *
root=Tk()
def fun():
    print("I won't do anything")
MainMenu=Menu(root)
root.config(menu=MainMenu)
SubMenu=Menu(MainMenu)
MainMenu.add_cascade(label='File',menu=SubMenu)
SubMenu.add_command(label='New_project',command=fun)
SubMenu.add_command(label='New..',command=fun)
SubMenu.add_command(label='Save',command=fun)
SubMenu.add_command(label='Save_As',command=fun)
SubMenu.add_separator()
SubMenu.add_command(label='Exit',command=fun)
SubMenu1=Menu(MainMenu)
SubMenu2=Menu(MainMenu)
SubMenu3=Menu(MainMenu)
MainMenu.add_cascade(label='Edit',menu=SubMenu1)
MainMenu.add_cascade(label='View',menu=SubMenu2)
MainMenu.add_cascade(label='Help',menu=SubMenu3)
SubMenu1.add_command(label='Edit_stuff',command=fun)
SubMenu2.add_command(label='View_stuff',command=fun)
SubMenu3.add_command(label='Help!!',command=fun)
equa=''
equation=StringVar()
equation.set('0')
def clear():
    global equa
    equa=''
    equation.set('')
def buttonPress(num):
    global equa
    equa=equa+str(num)
    equation.set(equa)
def equalPress():
    global equa
    total=str(eval(equa))
    equation.set(total)
    equa=''
frame=Frame(root)
frame.pack(side=BOTTOM)
root.title('Calculator')
topFrame=Frame(root)
topFrame.pack(side=TOP)
txtDisplay=Entry(topFrame,textvariable=equation,bd=15,font=30)
txtDisplay.pack(side=TOP)
Button0=Button(frame,text='0',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress(0))
Button0.grid(row=4,column=1)
Button1=Button(frame,text='1',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress(1))
Button1.grid(row=1,column=0)
Button2=Button(frame,text='2',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress(2))
Button2.grid(row=1,column=1)
Button3=Button(frame,text='3',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress(3))
Button3.grid(row=1,column=2)
Button4=Button(frame,text='4',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress(4))
Button4.grid(row=2,column=0)
Button5=Button(frame,text='5',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress(5))
Button5.grid(row=2,column=1)
Button6=Button(frame,text='6',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress(6))
Button6.grid(row=2,column=2)
Button7=Button(frame,text='7',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress(7))
Button7.grid(row=3,column=0)
Button8=Button(frame,text='8',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress(8))
Button8.grid(row=3,column=1)
Button9=Button(frame,text='9',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress(9))
Button9.grid(row=3,column=2)
Plus=Button(frame,text='+',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress('+'))
Plus.grid(row=1,column=3)
Minus=Button(frame,text='-',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress('-'))
Minus.grid(row=2,column=3)
Divide=Button(frame,text='/',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress('/'))
Divide.grid(row=3,column=3)
Multiply=Button(frame,text='*',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress('*'))
Multiply.grid(row=4,column=3)
square=Button(frame,text='^2',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress('**2'))
square.grid(row=1,column=4)
cube=Button(frame,text='^3',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress('**3'))
cube.grid(row=2,column=4)
dot=Button(frame,text='.',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress('.'))
dot.grid(row=4,column=2)
sqrt=Button(frame,text='√',padx=10,pady=10,bd=8,fg='black',command=lambda : buttonPress('**0.5'))
sqrt.grid(row=3,column=4)
Equal=Button(frame,text='=',padx=10,pady=10,bd=8,fg='black',command=equalPress)
Equal.grid(row=4,column=4)
Clear=Button(frame,text='C',padx=10,pady=10,bd=8,fg='black',command=clear)
Clear.grid(row=4,column=0)
root.mainloop()
