-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEje3.py
58 lines (50 loc) · 2.04 KB
/
Eje3.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
from tkinter import *
import os
##############################################################################################
carpetaDeTodosLosArchivos = os.path.dirname(__file__)
carpetaLogo = os.path.join(carpetaDeTodosLosArchivos, "logo")
##############################################################################################
ventana = Tk()
ventana.geometry("500x300")
ventana.title("Ejercicio N°3")
ventana.iconbitmap(os.path.join(carpetaLogo, "perropepsi.ico"))
tipotexto = "Comic Sans MS", 10, "italic"
##############################################################################################
Label(ventana, background="Brown1", text="~ VictoriaVMC", font=tipotexto,
justify=CENTER).pack(side=BOTTOM, fill=BOTH, expand=False)
##############################################################################################
Label(ventana, text="Altura (metros)").place(x=105, y=30)
Label(ventana, text="Peso (kg)").place(x=135, y=60)
n1 = DoubleVar()
n2 = DoubleVar()
Entry(ventana, textvariable=n1).place(x=200, y=30)
Entry(ventana, textvariable=n2).place(x=200, y=60)
resultado = StringVar()
Entry(ventana, state="readonly", width=38,
textvariable=resultado).place(x=200, y=160)
def imc():
num1 = n1.get()
num2 = n2.get()
if (num1 > 0) and (num2 > 0):
calculador = (num2/(num1*num1))
if calculador < 18.5:
texto = "Bajo peso."
elif calculador < 24.9:
texto = "Normal."
elif calculador < 29.9:
texto = "Sobrepeso."
elif calculador < 34.8:
texto = "Obesidad."
elif calculador < 34.9:
texto = "Obesidad I"
elif calculador < 39.9:
texto = "Obesidad II"
else:
texto = "Obesidad III"
Label(ventana, text=f"Presenta {texto}").place(x=200, y=135)
mostrar = round(calculador, 2)
else:
mostrar = "Los datos ingresados deben ser mayor a 0."
return resultado.set(mostrar)
Button(ventana, text="Calcular IMC", command=imc, width=16).place(x=60, y=160)
ventana.mainloop()