-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculadora-BETA.py
69 lines (58 loc) · 2.15 KB
/
Calculadora-BETA.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
# OBJECTIVE: Calculadora de Figuras e Sólidos Geométricos
import PySimpleGUI as sg
pi = 3.14
# square-retangule-quadrilateral-figure
def Quadrilateral (h, w):
area = (h * w)
print("Area: ", area," m²")
def Triangule (h, w):
area = h * w / 2
print("Area: ", area," m²")
def Trapeze (h, m_base, l_base):
area = (h * (m_base + l_base))/ 2
print("Area: ", area, " m²")
def Circle (r):
area = (4)*(pi)*((r)**2)
print("Area: ", area, " m²")
class Screen:
def __init__(self):
#Layout
layout = [
[sg.Text('Select form:', size=(10,0)),sg.Input(size=(15,0),key='form')],
[sg.Text('Put the value(m):', size=(10, 0)), sg.Input(size=(15, 0), key='input_1')],
[sg.Text('Put the value(m):', size=(10, 0)), sg.Input(size=(15, 0), key='input_2')],
[sg.Text('Put the value(m):', size=(10, 0)), sg.Input(size=(15, 0), key='input_3')],
[sg.Text('Result: ', size=(10,0)),sg.Input(size=(15,0),key='result')],
[sg.Button("Calculate")],
[sg.Output(size=(30,20))]
]
#Window
self.window = sg.Window("Values").layout(layout)
#Extracting values
self.button, self.values = self.window.Read()
def Iniciate(self):
while True:
self.button, self.values = self.window.Read()
'''
form = self.form['form']
area = self.area['result']
print(f'Form: {self.form}')
if form == '1':
h = self.values['input_1']
w = self.values['input_2']
Quadrilateral(h, w)
elif form == '2':
h = self.values['input_1']
w = self.values['input_1']
Triangule(h, w)
elif form == '3':
h = self.values['input_1']
m_base = self.values['input_2']
l_base = self.values['input_3']
Trapeze(h, m_base, l_base)
elif form == '4':
r = self.values['input_1']
Circle(r)
'''
tela = Screen()
tela.Iniciate()