forked from iabhigupta/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12_2.py
More file actions
79 lines (54 loc) · 1.17 KB
/
12_2.py
File metadata and controls
79 lines (54 loc) · 1.17 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
70
71
72
73
74
75
76
77
78
79
from tkinter import *
top = Tk()
a=0
b=0
x=0
def print_contents() :
#global x
x=v.get()
a=contents1.get()
b=contents2.get()
print("%s %s"%(a,b))
if x==1:
c=a+b
print(c)
contents3.set(c)
elif x==2:
c=a-b
print(c)
contents3.set(c)
elif x==3:
c=a*b
print(c)
contents3.set(c)
elif x==4:
c=a/b
print(c)
contents3.set(c)
v = IntVar()
rb1 = Radiobutton(text='add', value="1", variable=v, command=print_contents)
rb2 = Radiobutton(text='subtract', value="2", variable=v, command=print_contents)
rb3 = Radiobutton(text='multiply', value="3", variable=v, command=print_contents)
rb4 = Radiobutton(text='divide', value="4", variable=v, command=print_contents)
rb1.pack(anchor=W);
rb2.pack(anchor=W);
rb3.pack(anchor=W);
rb4.pack(anchor=W);
entry1 = Entry(top, width=50)
entry1.pack()
contents1 = IntVar()
contents1.set("")
entry1["textvariable"] = contents1
entry2 = Entry(top, width=50)
entry2.pack()
contents2 = IntVar()
contents2.set("")
entry2["textvariable"] = contents2
label = Label(top, text='Result:')
label.pack()
entry3=Entry(top, width=50)
entry3.pack()
contents3=IntVar()
contents3.set("")
entry3["textvariable"]= contents3
mainloop()