-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
76 lines (58 loc) · 3.2 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#Code - Sri Balaji Muruganandam
from tkinter import *
import os
di=os.path.dirname(__file__)
root=Tk()
root.title("CalX")
root.configure(background="#232232")
root.resizable(0,0) #disables the maximize button
ph=PhotoImage(file=os.path.join(di,"ico.png"))
root.iconphoto(False,ph)
def equal():
a=e.get()
e.delete(0,END)
try:
e.insert(0,eval(a))
except SyntaxError as s:
e.insert(0,"Invalid")
def enter(s):
a=e.get()
e.delete(0,END)
e.insert(0,a+s)
def clear():
e.delete(0,END)
e=Entry(root,borderwidth=5,fg="#232232",bg="#fdfae5",width=20,font=('Ubuntu',22))
b1=Button(root,text="1",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("1"))
b2=Button(root,text="2",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("2"))
b3=Button(root,text="3",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("3"))
b4=Button(root,text="4",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("4"))
b5=Button(root,text="5",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("5"))
b6=Button(root,text="6",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("6"))
b7=Button(root,text="7",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("7"))
b8=Button(root,text="8",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("8"))
b9=Button(root,text="9",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("9"))
b0=Button(root,text="0",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("0"))
e.grid(row=0,column=0,columnspan=4,padx=5,pady=5)
b1.grid(row=1,column=0,padx=5,pady=5)
b2.grid(row=1,column=1,padx=5,pady=5)
b3.grid(row=1,column=2,padx=5,pady=5)
b4.grid(row=2,column=0,padx=5,pady=5)
b5.grid(row=2,column=1,padx=5,pady=5)
b6.grid(row=2,column=2,padx=5,pady=5)
b7.grid(row=3,column=0,padx=5,pady=5)
b8.grid(row=3,column=1,padx=5,pady=5)
b9.grid(row=3,column=2,padx=5,pady=5)
b0.grid(row=4,column=1,padx=5,pady=5)
be=Button(root,text="=",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=equal)
ba=Button(root,text="+",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("+"))
bs=Button(root,text="-",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("-"))
bd=Button(root,text="/",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("/"))
bm=Button(root,text="*",padx=30,pady=25,fg="#232232",bg="#f5ea92",font=('Ubuntu',14,"bold"),command=lambda:enter("*"))
bclear=Button(root,text="CLR",padx=25,pady=27,fg="#232232",bg="#f5ea92",font=('Ubuntu',12,"bold"),command=clear)
be.grid(row=4,column=2,padx=5,pady=5)
ba.grid(row=4,column=3,padx=5,pady=5)
bs.grid(row=3,column=3,padx=5,pady=5)
bd.grid(row=1,column=3,padx=5,pady=5)
bm.grid(row=2,column=3,padx=5,pady=5)
bclear.grid(row=4,column=0,padx=5,pady=5)
root.mainloop()