-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
85 lines (56 loc) · 1.87 KB
/
main.py
File metadata and controls
85 lines (56 loc) · 1.87 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
80
81
82
83
84
85
import math
import tkinter as tk
from tkinter import *
import numpy as np
window = Tk()
window.title("")
window.geometry('500x200')
A = StringVar()
B = StringVar()
def ClkPlus():
a = float(A.get())
b = float(B.get())
res = a + b
textRes.configure(text="Результат: \n" + str(res))
def ClkMinus():
a = float(A.get())
b = float(B.get())
res = a - b
textRes.configure(text="Результат: \n" + str(res))
def ClkDiv():
a = float(A.get())
b = float(B.get())
res = a / b
textRes.configure(text="Результат: \n" + str(res))
def ClkMult():
a = float(A.get())
b = float(B.get())
res = a * b
textRes.configure(text="Результат: \n" + str(res))
mainmenu = Menu(window)
window.config(menu=mainmenu)
menuFunc = Menu(mainmenu, tearoff=0)
menuFunc.add_command(label='Сложить', command=ClkPlus)
menuFunc.add_command(label='Вычесть', command=ClkMinus)
menuFunc.add_command(label='Делить', command=ClkDiv)
menuFunc.add_command(label='Умножить', command=ClkMult)
mainmenu.add_cascade(label='Действия', menu=menuFunc)
textA = Label(window, text="A")
textA.grid(column=0, row=1)
txtInpA = Entry(window, width=15, textvariable=A)
txtInpA.grid(column=0, row=2)
textB = Label(window, text="B")
textB.grid(column=1, row=1)
txtInpB = Entry(window, width=15, textvariable=B)
txtInpB.grid(column=1, row=2)
textRes = Label(window, width=10, text="Результат: ")
textRes.grid(column=0, row=3)
btnPlus = Button(window, width=10, text="+", command=ClkPlus)
btnPlus.grid(column=0, row=6)
btnMinus = Button(window, width=10, text="-", command=ClkMinus)
btnMinus.grid(column=1, row=6)
btnDiv = Button(window, width=10, text="/", command=ClkDiv)
btnDiv.grid(column=2, row=6)
btnMult = Button(window, width=10, text="*", command=ClkMult)
btnMult.grid(column=3, row=6)
window.mainloop()