-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimplecalc.py
More file actions
69 lines (64 loc) · 2.32 KB
/
Copy pathsimplecalc.py
File metadata and controls
69 lines (64 loc) · 2.32 KB
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
from tkinter import *
m=Tk()
m.title('simple calculator')
def add():
e3.delete(0,END)
res=int(e1.get())+ int(e2.get())
e3.insert(0,res)
def sub():
e3.delete(0,END)
res=int(e1.get())- int(e2.get())
e3.insert(0,res)
def mul():
e3.delete(0,END)
res=int(e1.get())*int(e2.get())
e3.insert(0,res)
def div():
e3.delete(0,END)
res=int(e1.get())/int(e2.get())
e3.insert(0,res)
def mod():
e3.delete(0,END)
res=int(e1.get())% int(e2.get())
e3.insert(0,res)
def pow():
e3.delete(0,END)
res=int(e1.get())** int(e2.get())
e3.insert(0,res)
def cls():
e3.delete(0,END)
e1.delete(0, END)
e2.delete(0, END)
c=Canvas(m,width=350,height=400,bg='grey')
c.pack()
l1=Label(m,text='Simple calculator',font=('times',14,'bold'),bg='green')
c.create_window(160,40,window=l1)
l2=Label(m,text='Enter no1',font=('times',12,),bg='pink',width=14)
c.create_window(100,100,window=l2)
l3=Label(m,text='Enter no2',font=('times',12),bg='pink',width=14)
c.create_window(100,140,window=l3)
l4=Label(m,text='Result',font=('times',12,'bold'),bg='gold',width=14)
c.create_window(100,180,window=l4)
e1=Entry(m,bd=4)
c.create_window(260,100,window=e1)
e2=Entry(m,bd=4)
c.create_window(260,140,window=e2)
e3=Entry(m,bd=4)
c.create_window(260,180,window=e3)
b1=Button(text="+",command=add,bg='purple',fg='white',font=('times',12,'bold'),width=5)
c.create_window(40,250,window=b1)
b2=Button(text="-",command=sub,bg='purple',fg='white',font=('times',12,'bold'),width=5)
c.create_window(80,250,window=b2)
b3=Button(text="*",command=mul,bg='purple',fg='white',font=('times',12,'bold'),width=5)
c.create_window(120,250,window=b3)
b4=Button(text="/",command=div,bg='purple',fg='white',font=('times',12,'bold'),width=5)
c.create_window(160,250,window=b4)
b5=Button(text="%",command=mod,bg='purple',fg='white',font=('times',12,'bold'),width=5)
c.create_window(200,250,window=b5)
b6=Button(text="^",command=pow,bg='purple',fg='white',font=('times',12,'bold'),width=5)
c.create_window(240,250,window=b6)
b7=Button(text="CLS",command=cls,bg='purple',fg='white',font=('times',12,'bold'),width=5)
c.create_window(280,250,window=b7)
b8=Button(text="close",command=m.destroy,bg='purple',fg='white',font=('times',12,'bold'),width=5)
c.create_window(160,330,window=b8)
m.mainloop()