from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
import kod
def human_index(m, h):
hindex = str(round(m / (h * h), 1) )
return {'hindex': hindex}
class MenuScreen(Screen):
def calculate(self):
try:
mass = float(self.second.text)
heigth = float(self.first.text)
human_i = human_index(mass, heigth)
gets = human_i.get('hindex')
self.third.text = "Ваш результат: " + str(gets)
self.first.text = ""
self.second.text = ""
if 16.5 > float(gets):
self.fourth.text = "Крайний недостаток веса"
elif 16.5 < float(gets) < 18.4:
self.fourth.text = "Недостаток веса"
elif 18.5 < float(gets) < 24.9:
self.fourth.text = "Нормальный вес"
elif 25 < float(gets) < 30:
self.fourth.text = "Избыточная масса"
elif 30.01 < float(gets) < 34.9:
self.fourth.text = "Ожирение(Клас I)"
elif 35 < float(gets) < 40:
self.fourth.text = "Ожирение(Клас II)"
elif 40 < float(gets) < 70:
self.fourth.text = "Ожирение(Клас III)"
elif 71 < float(gets):
self.fourth.text = "А ты шутник"
except:
self.third.text = "Вы не ввели число"
self.first.text = ""
self.second.text = ""
self.fourth.text = "----------"
class SettingsScreen(Screen):
pass
sm = ScreenManager()
sm.add_widget(SettingsScreen(name='settings'))
sm.add_widget(MenuScreen(name='menu'))
class Myapp(MDApp):
def __init__(self, **kwargs):
self.title = "My app"
super().__init__(**kwargs)
def build(self):
return sm
if __name__ == "__main__":
Myapp().run()