forked from harshitbansal373/hacktoberfest2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculator.py
33 lines (25 loc) · 974 Bytes
/
Calculator.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
from tkinter import *
root=Tk()
root.title('My Calculator')
root.config(bg='gainsboro')
list=[]
e=Entry(root,bg='azure',fg='black',font='times 35 italic',justify='right')
e.grid(row=0,column=0,padx=5,pady=5,sticky='nswe',columnspan=4) #columnspan imp in grid for giving size of two or more buttons
l=['C','DEL']
def Display1(event):
b['bg']='sky blue'
def Display2(event):
b['bg']='gray66'
for i in range(0,4,2):
b=Button(root,text=l.pop(),bg='gray70',fg='black',font='times 20 ')
b.grid(row=1,column=i,padx=5,pady=5,sticky='nswe',columnspan=2)
l1=['789/','456X','123=','.0+-']
for i in range(4):
for j in range(4):
list.append(Button(root,text=l1[i][j],bg='gray66',fg='black',font='times 20 bold',commad=lambda x=l[i][j]:Display(x)))
list[-1].grid(row=i+2,column=j,padx=5,pady=5,sticky='nswe')
for i in range(7):
root.grid_rowconfigure(i,weight=1)
for j in range(4):
root.grid_columnconfigure(j,weight=1)
root.mainloop()