Advertisement
shh_algo_PY

Ruffier Part 1 - MVP

Mar 11th, 2023 (edited)
891
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.52 KB | None | 0 0
  1. # Ruffier App, with notes :) - Ms. Suraya
  2.  
  3. # All of the imports!
  4. from kivy.app import App
  5. from kivy.uix.screenmanager import ScreenManager, Screen
  6. from kivy.uix.boxlayout import BoxLayout
  7. from kivy.uix.label import Label
  8. from kivy.uix.button import Button
  9. from kivy.uix.textinput import TextInput
  10. from kivy.core.window import Window
  11. from kivy.uix.scrollview import ScrollView
  12. from instructions import txt_instruction, txt_test1, txt_test2, txt_test3, txt_sits
  13. from ruffier import test
  14.  
  15. # Variables to store all the default settings for the text boxes
  16. age = 7
  17. name = ""
  18. p1, p2, p3 = 0, 0, 0
  19.  
  20. # Instruction screen 🖥️
  21. # Instructions are taken from instructions.py
  22. # There are two pairs of Labels and TextInput
  23. # Label 1 + TextInput --- User enters name
  24. # Label 2 + TextInput --- User enters age
  25. # There is one button "Start" that will take the user to the next step
  26.  
  27. class InstrScr(Screen):
  28.     def __init__(self, **kwargs):
  29.         super().__init__(**kwargs)
  30.         instr = Label(text=txt_instruction)
  31.         lbl1 = Label(text='Enter the name:', halign='right')
  32.         self.in_name = TextInput(multiline=False)
  33.         lbl2 = Label(text='Enter the age:', halign='right')
  34.         self.in_age = TextInput(text='7', multiline=False)
  35.         self.btn = Button(text='Start', size_hint=(0.3, 0.2), pos_hint={'center_x': 0.5})
  36.         self.btn.on_press = self.next
  37.         line1 = BoxLayout(size_hint=(0.8, None), height='30sp')
  38.         line2 = BoxLayout(size_hint=(0.8, None), height='30sp')
  39.         line1.add_widget(lbl1)
  40.         line1.add_widget(self.in_name)
  41.         line2.add_widget(lbl2)
  42.         line2.add_widget(self.in_age)
  43.         outer = BoxLayout(orientation='vertical', padding=8, spacing=8)
  44.         outer.add_widget(instr)
  45.         outer.add_widget(line1)
  46.         outer.add_widget(line2)
  47.         outer.add_widget(self.btn)
  48.         self.add_widget(outer)
  49.  
  50.     def next(self):
  51.             global name
  52.             name = self.in_name.text
  53.             self.manager.current = 'pulse1'
  54.  
  55. # Pulse measuring screen! 💓
  56. # Intructions are from instructions.py
  57. # Label + TextInput --- to enter measured pulse (Resting)
  58. # One button to take user to the next step
  59.  
  60. class PulseScr(Screen):
  61.     def __init__(self, **kwargs):
  62.         super().__init__(**kwargs)
  63.        
  64.         instr = Label(text=txt_test1)
  65.        
  66.         line = BoxLayout(size_hint=(0.8, None), height='30sp')
  67.    
  68.         lbl_result = Label(text='Enter the result:', halign='right')
  69.         self.in_result = TextInput(text='0', multiline=False)
  70.        
  71.         line.add_widget(lbl_result)
  72.         line.add_widget(self.in_result)
  73.    
  74.         self.btn = Button(text='Next', size_hint=(0.3, 0.2), pos_hint={'center_x': 0.5})
  75.         self.btn.on_press = self.next
  76.    
  77.         outer = BoxLayout(orientation='vertical', padding=8, spacing=8)
  78.         outer.add_widget(instr)
  79.         outer.add_widget(line)
  80.         outer.add_widget(self.btn)
  81.         self.add_widget(outer)
  82.    
  83.     def next(self):
  84.         global p1
  85.         p1 = int(self.in_result.text)
  86.         self.manager.current = 'sits'
  87.  
  88. # SQUAT SQUAT SQUAT
  89. # Shows instructions from instructions.py
  90. # Signals the user to squat 30 times in 45 seconds
  91. # Note: No timers yet!
  92. # One button to go to the next screen
  93.  
  94. class CheckSits(Screen):
  95.     def __init__(self, **kwargs):
  96.         super().__init__(**kwargs)
  97.    
  98.         instr = Label(text=txt_sits)
  99.    
  100.         self.btn = Button(text='Next', size_hint=(0.3, 0.2), pos_hint={'center_x': 0.5})
  101.         self.btn.on_press = self.next
  102.    
  103.         outer = BoxLayout(orientation='vertical', padding=8, spacing=8)
  104.         outer.add_widget(instr)
  105.         outer.add_widget(self.btn)
  106.         self.add_widget(outer)
  107.    
  108.     def next(self):
  109.         self.manager.current = 'pulse2'
  110.  
  111. # Final pulse readings 💓
  112. # Instructions are taken from... you guessed it: instructions.py
  113. # There are two pairs of Labels and TextInput
  114. # Label 1 + TextInput --- Pulse right after all the squats
  115. # Label 2 + TextInput --- Pulse taken again after resting
  116. # One button "Finalise" that will take the user to the next step
  117.  
  118. class PulseScr2(Screen):
  119.     def __init__(self, **kwargs):
  120.         pass
  121.    
  122.     def next(self):
  123.         pass
  124.  
  125. # Results screen 🖥️
  126. # Displays Name, Ruffier Index and Heart Efficiency
  127.  
  128. class Result(Screen):
  129.     def __init__(self, **kwargs):
  130.         pass
  131.    
  132.     def before(self):
  133.         pass
  134.  
  135. # Tying it all together!
  136.  
  137. class HeartCheck(App):
  138.     def build(self):
  139.         pass
  140.  
  141. # Run the app ✨
  142.  
  143. app = HeartCheck()
  144. app.run()
  145.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement