Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
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()
from kivy.lang import Builder Builder.load_string(""" : GridLayout: first: text_mass second: text_heigth third: label fourth: labels rows: 5 padding: 30 spacing: 5 MDLabel: id: label size_hint: 1, 0.4 font_name: "data/fonts/RobotoMono-Regular.ttf" text: 'Веддите данные' font_size: '30sp' MDLabel: id: labels font_name: "data/fonts/RobotoMono-Regular.ttf" text: '----------' size_hint: 1, 0.2 font_size: '24sp' MDTextField: id: text_mass hint_text: 'Введите рост' size_hint: 1, 0.2 multiline: False font_size: '20sp' MDTextField: id: text_heigth hint_text: 'Введите вес' size_hint: 1, 0.2 multiline: False font_size: '20sp' FloatLayout: MDFillRoundFlatButton: size_hint: 0.8, 0.22 font_size: '30sp' background_color: .73, .05, .05, 1 font_name: "data/fonts/RobotoMono-Regular.ttf" pos_hint: {'center_x': 0.5, 'y': 0.5} text: 'Расчитать' on_release: root.calculate() MDFillRoundFlatButton: size_hint: 0.8, 0.2 spacing: background_color: .73, .05, .05, 1 font_size: '30sp' font_name: "data/fonts/RobotoMono-Regular.ttf" pos_hint: {'center_x': 0.5, 'y': 0.28} text: 'Настройки' on_release: """)