Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ed28e17

Browse files
finalizandoLogicaIMC
1 parent 164fd02 commit ed28e17

File tree

8 files changed

+61
-14
lines changed

8 files changed

+61
-14
lines changed

‎__pycache__/calculadora.cpython-310.pyc

69 Bytes
Binary file not shown.

‎__pycache__/imc.cpython-310.pyc

1.62 KB
Binary file not shown.

‎__pycache__/main.cpython-310.pyc

1.04 KB
Binary file not shown.

‎calculadora.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ def botao_igual():
155155

156156

157157
def botao_voltar():
158+
import main
159+
main.tela_main.show()
160+
app.exec()
158161
tela_calculadora.close()
159162

160163

‎imc.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
11
from PyQt5 import uic, QtWidgets, QtGui
22

33

4+
def chama_voltar():
5+
import main
6+
main.tela_main.show()
7+
app.exec()
8+
tela_imc.close()
9+
10+
411
def calcular_imc():
5-
peso = tela_imc.txt_peso.text()
12+
peso = str(tela_imc.txt_peso.text())
13+
peso = peso.replace(',', '.')
614
peso = float(peso)
7-
altura = tela_imc.txt_altura.text()
15+
16+
altura = str(tela_imc.txt_altura.text())
17+
altura = altura.replace(',', '.')
818
altura = float(altura)
9-
imc = peso / (altura**2)
10-
tela_imc.label_resultado.setText(f'IMC: {imc}')
19+
20+
imc = float(round(peso / (altura * altura), 2))
21+
22+
if imc <= 18.5:
23+
tela_imc.label_mensagem.setText(' Classificação: Magreza - Obsidade: Grau 0 ')
24+
elif 18.5 < imc <= 24.9:
25+
tela_imc.label_mensagem.setText(' Classificação: Normal - Obsidade: Grau 0')
26+
elif 25.0 < imc <= 29.9:
27+
tela_imc.label_mensagem.setText(' Classificação: Sobrepeso - Obsidade: Grau I')
28+
elif 30.0 < imc <= 39.9:
29+
tela_imc.label_mensagem.setText(' Classificação: Obesidade - Obsidade: Grau II')
30+
elif imc >= 40.0:
31+
tela_imc.label_mensagem.setText(' Classificação: Obsidade Grave - Obsidade: Grau III')
32+
33+
tela_imc.label_resultado.setText(f' IMC: {imc}')
1134

1235

1336
app = QtWidgets.QApplication([])
1437
tela_imc = uic.loadUi('tela_imc.ui')
1538
tela_imc.setWindowIcon(QtGui.QIcon('imagens/imc-icon.png'))
1639
tela_imc.setWindowTitle('Calcular IMC')
1740

41+
tela_imc.txt_peso.setInputMask('000,00')
42+
tela_imc.txt_altura.setInputMask('0,00')
43+
1844
tela_imc.btn_calcular.clicked.connect(calcular_imc)
45+
tela_imc.btn_voltar.clicked.connect(chama_voltar)
1946

2047
tela_imc.show()
2148
app.exec()
22-

‎main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ def chamar_calculadora():
99
import calculadora
1010
calculadora.tela_calculadora.show()
1111
calculadora.app.exec()
12+
tela_main.close()
1213

1314

1415
def chamar_imc():
15-
print('chamei imc :)')
16+
import imc
17+
imc.tela_imc.show()
18+
imc.app.exec()
19+
tela_main.close()
1620

1721

1822
app = QtWidgets.QApplication([])

‎tela_calculadora.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>630</width>
10-
<height>633</height>
9+
<width>428</width>
10+
<height>580</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">

‎tela_imc.ui

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>427</width>
9+
<width>428</width>
1010
<height>579</height>
1111
</rect>
1212
</property>
@@ -68,6 +68,9 @@ color: white;</string>
6868
</item>
6969
<item>
7070
<widget class="QLineEdit" name="txt_peso">
71+
<property name="enabled">
72+
<bool>true</bool>
73+
</property>
7174
<property name="sizePolicy">
7275
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
7376
<horstretch>0</horstretch>
@@ -82,23 +85,28 @@ color: white;</string>
8285
</property>
8386
<property name="maximumSize">
8487
<size>
85-
<width>120</width>
88+
<width>80</width>
8689
<height>29</height>
8790
</size>
8891
</property>
8992
<property name="font">
9093
<font>
9194
<pointsize>12</pointsize>
95+
<strikeout>false</strikeout>
96+
<kerning>true</kerning>
9297
</font>
9398
</property>
9499
<property name="styleSheet">
95100
<string notr="true">background-color: rgb(255, 255, 255);</string>
96101
</property>
102+
<property name="inputMethodHints">
103+
<set>Qt::ImhPreferNumbers|Qt::ImhSensitiveData</set>
104+
</property>
97105
<property name="text">
98106
<string/>
99107
</property>
100108
<property name="maxLength">
101-
<number>9</number>
109+
<number>5</number>
102110
</property>
103111
<property name="cursorPosition">
104112
<number>0</number>
@@ -174,7 +182,7 @@ color: white;</string>
174182
</property>
175183
<property name="maximumSize">
176184
<size>
177-
<width>120</width>
185+
<width>80</width>
178186
<height>29</height>
179187
</size>
180188
</property>
@@ -190,7 +198,7 @@ color: white;</string>
190198
<string/>
191199
</property>
192200
<property name="maxLength">
193-
<number>9</number>
201+
<number>5</number>
194202
</property>
195203
<property name="alignment">
196204
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
@@ -261,6 +269,12 @@ border-bottom: 1px solid;
261269

262270
</string>
263271
</property>
272+
<property name="inputMethodHints">
273+
<set>Qt::ImhNone</set>
274+
</property>
275+
<property name="lineWidth">
276+
<number>1</number>
277+
</property>
264278
<property name="text">
265279
<string extracomment=" "> IMC: </string>
266280
</property>
@@ -318,7 +332,7 @@ border-bottom: 1px solid;
318332
</string>
319333
</property>
320334
<property name="text">
321-
<string> Mensagem</string>
335+
<string> Classificação:</string>
322336
</property>
323337
<property name="margin">
324338
<number>2</number>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /