forked from chaudhary19/Tkinter-Scientific_calc-and-Notepad
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmy_Calculator.py
209 lines (175 loc) · 6.98 KB
/
my_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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
from tkinter import *
import tkinter.messagebox as tmsg
import os
import time
from math import *
def getvals(event):
value = event.widget.cget('text')
if value=='Clr':
sc_variable.set('')
elif value=='=':
try:
sc_variable.set(eval(screen.get()))
screen.update()
except Exception as e:
sc_variable.set('Error - Wait for 3 sec')
screen.update()
status_var.set('Preparing...')
screen.update()
time.sleep(3)
sc_variable.set('')
screen.update()
status_var.set('Ready..')
screen.update()
else:
sc_variable.set(f'{sc_variable.get()}{value}')
def term_of_use():
tmsg.showinfo('Terms of Use ','IF YOU LIVE IN (OR IF YOUR PRINCIPAL PLACE OF BUSINESS IS IN) THE UNITED STATES, PLEASE READ THE BINDING ARBITRATION CLAUSE AND CLASS ACTION WAIVER IN SECTION 11. IT AFFECTS HOW DISPUTES ARE RESOLVED.')
def send_feedback():
ans=tmsg.askquestion('Feedback Hub','Was your experience good with us ? ')
if ans=='yes':
tmsg.showinfo('Feedback','Please Rate us on PlayStore')
else:
tmsg.showinfo('Feedback','We will contact you soon to know about your bad experience')
root=Tk()
canvas_width=555
canvas_height=620
root.geometry(f'{canvas_width}x{canvas_height}')
root.maxsize(canvas_width,canvas_height)
root.minsize(canvas_width,canvas_height)
root.title('CalCulator @ Chaudhary_19')
#root.wm_iconbitmap('calculator.png')
root.call('wm', 'iconphoto', root._w, PhotoImage(file='calculator.png'))
my_menu=Menu(root)
m1=Menu(my_menu,tearoff=0,fg='red')
m1.add_command(label='Terms of Use',command=term_of_use)
m1.add_command(label='Send Feedback',command=send_feedback)
root.config(menu=my_menu)
my_menu.add_cascade(label=' About ',menu=m1)
my_menu.add_command(label='Exit',command=quit)
sc_variable=StringVar()
screen=Entry(root,textvariable=sc_variable,font='lucida 35 bold',fg='blue',bg='black')
screen.pack(pady=10)
f=Frame(root)
f.pack()
b1=Button(f,text='7',font='lucida 30 bold',padx=5,borderwidth=2,fg='black',bg='gold')
b1.pack(side=LEFT,padx=5)
b2=Button(f,text='8',font='lucida 30 bold',padx=5,borderwidth=2,fg='black',bg='gold')
b2.pack(side=LEFT,padx=5)
b3=Button(f,text='9',font='lucida 30 bold',padx=5,borderwidth=2,fg='black',bg='gold')
b3.pack(side=LEFT,padx=5)
b4=Button(f,text='*',font='lucida 30 bold',padx=5,borderwidth=2,fg='yellow',bg='green')
b4.pack(side=LEFT,padx=5)
b5=Button(f,text='sin',font='lucida 30 bold',padx=5,borderwidth=2,fg='gold',bg='black')
b5.pack(side=LEFT,padx=5)
b6=Button(f,text='(',font='lucida 30 bold',padx=5,borderwidth=2,fg='yellow',bg='purple')
b6.pack(side=LEFT,padx=5)
b1.bind('<Button-1>',getvals)
b2.bind('<Button-1>',getvals)
b3.bind('<Button-1>',getvals)
b4.bind('<Button-1>',getvals)
b5.bind('<Button-1>',getvals)
b6.bind('<Button-1>',getvals)
buttons=[b1,b2,b3,b4,b5,b6]
count=0
for i in range(6):
buttons[count].grid(row=1,column=i)
count += 1
f=Frame(root)
f.pack()
b1=Button(f,text='4',font='lucida 30 bold',padx=5,borderwidth=2,fg='black',bg='gold')
b1.pack(side=LEFT,padx=5)
b2=Button(f,text='5',font='lucida 30 bold',padx=5,borderwidth=2,fg='black',bg='gold')
b2.pack(side=LEFT,padx=5)
b3=Button(f,text='6',font='lucida 30 bold',padx=5,borderwidth=2,fg='black',bg='gold')
b3.pack(side=LEFT,padx=5)
b4=Button(f,text='-',font='lucida 30 bold',padx=5,borderwidth=2,fg='yellow',bg='green')
b4.pack(side=LEFT,padx=5)
b5=Button(f,text='cos',font='lucida 30 bold',padx=5,borderwidth=2,fg='gold',bg='black')
b5.pack(side=LEFT,padx=5)
b6=Button(f,text=')',font='lucida 30 bold',padx=5,borderwidth=2,fg='yellow',bg='purple')
b6.pack(side=LEFT,padx=5)
b1.bind('<Button-1>',getvals)
b2.bind('<Button-1>',getvals)
b3.bind('<Button-1>',getvals)
b4.bind('<Button-1>',getvals)
b5.bind('<Button-1>',getvals)
b6.bind('<Button-1>',getvals)
buttons=[b1,b2,b3,b4,b5,b6]
count=0
for i in range(6):
buttons[count].grid(row=2,column=i)
count += 1
f=Frame(root)
f.pack()
b1=Button(f,text='1',font='lucida 30 bold',padx=5,borderwidth=2,fg='black',bg='gold')
b1.pack(side=LEFT,padx=5)
b2=Button(f,text='2',font='lucida 30 bold',padx=5,borderwidth=2,fg='black',bg='gold')
b2.pack(side=LEFT,padx=5)
b3=Button(f,text='3',font='lucida 30 bold',padx=5,borderwidth=2,fg='black',bg='gold')
b3.pack(side=LEFT,padx=5)
b4=Button(f,text='+',font='lucida 30 bold',padx=5,borderwidth=2,fg='yellow',bg='green')
b4.pack(side=LEFT,padx=5)
b5=Button(f,text='tan',font='lucida 30 bold',padx=5,borderwidth=2,fg='gold',bg='black')
b5.pack(side=LEFT,padx=5)
b6=Button(f,text='%',font='lucida 30 bold',padx=5,borderwidth=2,fg='yellow',bg='green')
b6.pack(side=LEFT,padx=5)
b1.bind('<Button-1>',getvals)
b2.bind('<Button-1>',getvals)
b3.bind('<Button-1>',getvals)
b4.bind('<Button-1>',getvals)
b5.bind('<Button-1>',getvals)
b6.bind('<Button-1>',getvals)
buttons=[b1,b2,b3,b4,b5,b6]
count=0
for i in range(6):
buttons[count].grid(row=3,column=i)
count += 1
f=Frame(root)
f.pack()
b1=Button(f,text='.',font='lucida 30 bold',padx=5,borderwidth=2,fg='yellow',bg='black')
b1.pack(side=LEFT,padx=5)
b2=Button(f,text='0',font='lucida 30 bold',padx=5,borderwidth=2,fg='black',bg='gold')
b2.pack(side=LEFT,padx=5)
b3=Button(f,text='=',font='lucida 30 bold',padx=5,borderwidth=2,fg='yellow',bg='green')
b3.pack(side=LEFT,padx=5)
b4=Button(f,text='/',font='lucida 30 bold',padx=5,borderwidth=2,fg='yellow',bg='green')
b4.pack(side=LEFT,padx=5)
b6=Button(f,text='log',font='lucida 30 bold',padx=5,borderwidth=2,fg='gold',bg='black')
b6.pack(side=LEFT,padx=5)
b5=Button(f,text='Clr',font='lucida 30 bold',padx=5,borderwidth=2,fg='yellow',bg='black')
b5.pack(side=LEFT,padx=5)
b1.bind('<Button-1>',getvals)
b2.bind('<Button-1>',getvals)
b3.bind('<Button-1>',getvals)
b4.bind('<Button-1>',getvals)
b5.bind('<Button-1>',getvals)
b6.bind('<Button-1>',getvals)
buttons=[b1,b2,b3,b4,b5,b6]
count=0
for i in range(6):
buttons[count].grid(row=4,column=i)
count += 1
f=Frame(root)
f.pack()
b1=Button(f,text='log10',font='lucida 15 bold',padx=20,pady=20,borderwidth=3,fg='black',bg='grey',width=3)
b2=Button(f,text='exp',font='lucida 15 bold',padx=20,pady=20,borderwidth=3,fg='black',bg='grey',width=3)
b3=Button(f,text='/',font='lucida 15 bold',padx=20,pady=20,borderwidth=3,fg='black',bg='grey',width=3)
b4=Button(f,text='Clr',font='lucida 15 bold',padx=20,pady=20,borderwidth=3,fg='black',bg='grey',width=3)
b5=Button(f,text='log',font='lucida 15 bold',padx=20,pady=20,borderwidth=3,fg='black',bg='grey',width=3)
b6=Button(f,text='=',font='lucida 15 bold',padx=20,pady=20,borderwidth=3,fg='black',bg='grey',width=3)
b1.bind('<Button-1>',getvals)
b2.bind('<Button-1>',getvals)
b3.bind('<Button-1>',getvals)
b4.bind('<Button-1>',getvals)
b5.bind('<Button-1>',getvals)
b6.bind('<Button-1>',getvals)
buttons=[b1,b2,b3,b4,b5,b6]
count=0
for i in range(6):
buttons[count].grid(row=5,column=i)
count += 1
status_var=StringVar()
status_var.set('Ready..')
Label(root,textvariable=status_var,relief=SUNKEN,anchor='w',borderwidth=3,bg='yellow',fg='red').pack(side=BOTTOM,fill=X)
root.mainloop()