forked from Techsrijan/mpsummer25
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtkinterplace.py
More file actions
57 lines (51 loc) · 1.54 KB
/
tkinterplace.py
File metadata and controls
57 lines (51 loc) · 1.54 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
from tkinter import *
from tkinter import messagebox
root=Tk()
def get_data():
# print(x.get())
if x.get()=='':
messagebox.showerror("Error",'Please enter the first value')
#res.set('Please enter the first value')
elif y.get()=='':
res.set('Please enter the second value')
else:
a=int(x.get())
b=int(y.get())
c=a+b
# print(c)
res.set(c)
def clear():
x.set('')
y.set('')
res.set('')
l1=Label(root,text="Enter First Number",
fg="red", bg="yellow",font=("Comic Sans Ms",10,"bold")
)
l1.place(x=10,y=50)
x=StringVar()
# x=IntVar()
text=Entry(root,justify='right',border="10",fg="red",font=("Comic Sans Ms",10,"bold"),textvariable=x)
text.place(x=200,y=50)
# for second row
l11=Label(root,text="Enter Second Number",
fg="red", bg="yellow",font=("Comic Sans Ms",10,"bold")
)
l11.place(x=10,y=150)
y=StringVar()
# x=IntVar()
text1=Entry(root,justify='right',border="10",fg="red",font=("Comic Sans Ms",10,"bold"),textvariable=y)
text1.place(x=200,y=150)
# creating a button
btn=Button(root,text="Add",fg="red",bg="yellow",
font=("Comic Sans Ms",15,"bold"),command=get_data)
btn.place(x=150,y=250)
btn_clear=Button(root,text="Clear",fg="red",bg="yellow",
font=("Comic Sans Ms",15,"bold"),command=clear)
btn_clear.place(x=300,y=250)
res=StringVar()
result=Label(root,fg="red", textvariable=res,font=("Comic Sans Ms",10,"bold")
)
result.place(x=150,y=350)
root.geometry("400x500+200+100")
root.resizable(0,0)
root.mainloop()