Skip to content

Commit 8c231cd

Browse files
Add files via upload
1 parent b6ebe36 commit 8c231cd

File tree

6 files changed

+60
-0
lines changed

6 files changed

+60
-0
lines changed

1.PNG

8.64 KB
Loading

2.PNG

8.48 KB
Loading

3.PNG

8.58 KB
Loading

4.PNG

8.62 KB
Loading

5.PNG

8.78 KB
Loading

arithmatic.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from tkinter import *
2+
class MyWindow:
3+
def __init__(self, win):
4+
self.lbl1=Label(win, text='First number')
5+
self.lbl2=Label(win, text='Second number')
6+
self.lbl3=Label(win, text='Result')
7+
self.t1=Entry(bd=3)
8+
self.t2=Entry()
9+
self.t3=Entry()
10+
self.btn1 = Button(win, text='Add')
11+
self.btn2=Button(win, text='Subtract')
12+
self.btn3=Button(win,text="Multilication")
13+
self.btn4=Button(win,text="Division")
14+
self.lbl1.place(x=100, y=50)
15+
self.t1.place(x=200, y=50)
16+
self.lbl2.place(x=100, y=100)
17+
self.t2.place(x=200, y=100)
18+
self.b1=Button(win, text='Add', command=self.add)
19+
self.b2=Button(win, text='Subtract')
20+
self.b2.bind('<Button-1>', self.sub)
21+
self.b3=Button(win,text="Multiplication")
22+
self.b3.bind('<Button-1>',self.mul)
23+
self.b4=Button(win,text="Divisin")
24+
self.b4.bind('<Button-1>',self.div)
25+
self.b1.place(x=100, y=150)
26+
self.b2.place(x=200, y=150)
27+
self.b3.place(x=300,y=150)
28+
self.b4.place(x=400,y=150)
29+
self.lbl3.place(x=100, y=200)
30+
self.t3.place(x=200, y=200)
31+
def add(self):
32+
self.t3.delete(0, 'end')
33+
num1=int(self.t1.get())
34+
num2=int(self.t2.get())
35+
result=num1+num2
36+
self.t3.insert(END, str(result))
37+
def sub(self, event):
38+
self.t3.delete(0, 'end')
39+
num1=int(self.t1.get())
40+
num2=int(self.t2.get())
41+
result=num1-num2
42+
self.t3.insert(END, str(result))
43+
def mul(self, event):
44+
self.t3.delete(0, 'end')
45+
num1=int(self.t1.get())
46+
num2=int(self.t2.get())
47+
result=num1*num2
48+
self.t3.insert(END, str(result))
49+
def div(self, event):
50+
self.t3.delete(0, 'end')
51+
num1=int(self.t1.get())
52+
num2=int(self.t2.get())
53+
result=num1/num2
54+
self.t3.insert(END, str(result))
55+
56+
window=Tk()
57+
mywin=MyWindow(window)
58+
window.title('Tkinter Arthematic operations')
59+
window.geometry("700x500+10+10")
60+
window.mainloop()

0 commit comments

Comments
 (0)