· 4 years ago · Feb 19, 2021, 02:32 AM
1from kivymd.app import MDApp
2from kivy.lang import Builder
3from kivymd.uix.dialog import MDDialog
4from kivymd.uix.button import MDFlatButton
5from kivy.uix.screenmanager import Screen
6from kivymd.uix.list import IRightBodyTouch, MDList
7from kivymd.uix.boxlayout import MDBoxLayout
8from kivymd.uix.expansionpanel import MDExpansionPanel, MDExpansionPanelTwoLine
9from kivy.uix.boxlayout import BoxLayout
10from kivy.properties import StringProperty
11from kivy.clock import Clock
12import json
13import sqlite3 as sql
14import datetime
15import time
16from news import News
17
18
19class NewsLayout(BoxLayout):
20 title = StringProperty()
21 picture = StringProperty(allownone=True)
22 description = StringProperty(allownone=True)
23
24class Content(MDList):
25 pass
26
27
28class RecordLine(MDBoxLayout):
29 text = StringProperty()
30
31
32class InformationDialog(MDDialog):
33 pass
34
35
36class MainMenuScreen(Screen):
37 pass
38
39class InputScreen(Screen):
40 pass
41
42class RestingHeartRateScreen(Screen):
43 pass
44
45class ResultObeseScreen(Screen):
46 pass
47
48class ResultNormalScreen(Screen):
49 pass
50
51class ResultOverweightScreen(Screen):
52 pass
53
54class ResultUnderweightScreen(Screen):
55 pass
56
57class LocationSearchScreen(Screen):
58 pass
59
60class LocationResultScreen(Screen):
61 pass
62
63class HistoryScreen(Screen):
64 pass
65
66class DemoApp(MDApp):
67
68
69 # conn = sql.connect('USERINFO.db')
70 # cur = conn.cursor()
71 # cur.execute(""" CREATE TABLE IF NOT EXISTS results (
72 # UID INTEGER PRIMARY KEY AUTOINCREMENT,
73 # NAME VARCHAR(50),
74 # RESULT INT,
75 # DATE_TIME TEXT DEFAULT CURRENT_TIMESTAMP)
76 # """)
77 # cur.execute(""" CREATE TABLE IF NOT EXISTS information (
78 # id INTEGER PRIMARY KEY AUTOINCREMENT,
79 # fname VARCHAR(50),
80 # height INT,
81 # weight INT,
82 # age INT,
83 # heartrate INT)
84 # """)
85 # conn.commit()
86 # conn.close()
87
88 def __init__(self, **kwargs):
89 super().__init__(**kwargs)
90 self.news = News() # create the Class instance
91 self.news.get_news() # pull a list of stories from the web
92 self.i = 0 # index for moving through the
93 self.list_items = [] # Dictionary where the items is stored
94 self.counter = 0
95 self.counting = {'Item counter': self.counter}
96 self.dialog = None
97 self.selected_category = None
98 self.selected_rec = None
99 self.card_file = \
100 [{'Category': 'Barangay ALABANG',
101 'Record': [
102 {'title': 'Alabang Medical Clinic ( MAIN )',
103 'Details': [
104 ' ADDRESS: \n 297 Montillano St, Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8842 0680']},
105 {'title': 'Alabang Medical Center, Alabang Zapote road',
106 'Details': [
107 ' ADDRESS: \n Ayala Life-FGU Center, Zapote Road Corner Acacia Avenue Madrigal Business Park, Ayala Alabang, Muntinlupa \n TELEPHONE NUMBER: \n 0998 855 9221']},
108 {'title': 'Asian Hospital and Medical Center',
109 'Details': [
110 ' ADDRESS: \n 2205 Civic Dr, Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8771 9000']},
111 {'title': 'Aventus Medical Care, Inc. - Alabang Clinic',
112 'Details': [
113 ' ADDRESS: \n 2/F Sycamore ARCS 1 Building Buencamino Street corner Alabang - Zapote Road Madrigal Business Park, Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8556 3598']},
114 {'title': 'Healthway Medical Festival Mall',
115 'Details': [
116 ' ADDRESS: \n 2nd Floor, Pixie Forest Entrance, Filinvest Ave, Filinvest City, Muntinlupa \n TELEPHONE NUMBER: \n (02) 751 4929']},
117 {'title': 'Healthfirst clinic ALABANG',
118 'Details': [
119 ' ADDRESS: \n G/F, South Supermarket, Filinvest Ave., Filinvest Corporate City \n TELEPHONE NUMBER: \n (+632) 8 821 1423 | 0917 842 8214']},
120 {'title': 'Ospital ng Muntinlupa ( OSMUN )',
121 'Details': [
122 ' ADDRESS: \n Civic Dr, Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8771 0457']},
123 {'title': 'St. Michaels Medical Center',
124 'Details': [
125 ' ADDRESS: \n Starmall Alabang, South Super Hwy, Alabang, Muntinlupa\n TELEPHONE NUMBER: \n 0921 624 4418']},
126 {'title': 'San Roque Medical Clinic',
127 'Details': [' ADDRESS: \n Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8842 2950']},
128 {'title': 'Megason Diagnostic Clinic',
129 'Details': [' ADDRESS: \nAlabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8809 9044']},
130 {'title': 'Tokyo Healthlink 東京ヘルスリンク - Alabang',
131 'Details': [
132 ' ADDRESS: \n Molito Complex, Madrigal Ave, Ayala Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8772 2678']},
133 {'title': 'Research Institute for Tropical Medicine',
134 'Details': [
135 ' ADDRESS: \n Filinvest Corporate City, 9002 Research Dr, Alabang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8807 2631']},
136 ]},
137 {'Category': 'Barangay BAYANAN',
138 'Record': [
139 {'title': 'Silverio Medical Clinic',
140 'Details': [
141 ' ADDRESS: \n 233g National Road, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8862 0223']},
142 {'title': 'Bayanan Health Center (Annex)',
143 'Details': [
144 ' ADDRESS: \n Block 2, Purok 1, 292 M Dolleton St, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8862 0124']},
145 {'title': 'Bayanan Medical Clinic, X-Ray and Laboratory Services',
146 'Details': [
147 ' ADDRESS: \n 231 National Road, Bayanan, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8861 5861']},
148 {'title': 'El Natividad Medical And Maternity Clinic',
149 'Details': [
150 ' ADDRESS: \n 214 National Road, Muntinlupa \n TELEPHONE NUMBER: \n 0923 701 5164']},
151 ]},
152 {'Category': 'Barangay CUPANG',
153 'Record': [
154 {'title': 'Hillside General Hospital',
155 'Details': [
156 ' ADDRESS: \n Km. 23, West Service Road, Cupang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8842 3958']},
157 {'title': 'Alabang Medical Center',
158 'Details': [
159 ' ADDRESS: \n 8 Corregidor, Cupang, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8850 8719']},
160 {'title': 'Cupang Health Center',
161 'Details': [
162 ' ADDRESS: \n Barangay Hall, Beside Cupang, Manuel L. Quezon, Cupang, Muntinlupa \n TELEPHONE NUMBER: \n --']},
163 ]},
164 {'Category': 'Barangay POBLACION',
165 'Record': [
166 {'title': 'Albia Medical & Diagnostic Clinic',
167 'Details': [
168 ' ADDRESS: \n 93 Rizal St, Poblacion, Muntinlupa \n TELEPHONE NUMBER: \n (02)8461204']},
169 {'title': 'Babaran Echavez Medical And Psychiatric Clinic',
170 'Details': [
171 ' ADDRESS: \n 1125 Amparo Corner Sto Nino Street, Poblacion, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8861 3066']},
172 {'title': 'MCC De La Merced Maternity And Childrens Clinic',
173 'Details': [
174 ' ADDRESS: \n 92 Rizal St, Poblacion, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8861 3944']},
175 {'title': 'Mauricestela Medical Clinic',
176 'Details': [
177 ' ADDRESS: \n 212 Pedro Diaz St, Poblacion, Muntinlupa, 1776 Metro Manila \n TELEPHONE NUMBER: \n (02) 8862 2117']},
178 {'title': 'Poblacion Health Center Main',
179 'Details': [
180 ' ADDRESS: \n Poblacion, Muntinlupa \n TELEPHONE NUMBER: \n NONE']},
181 ]},
182 {'Category': 'Barangay PUTATAN',
183 'Record': [
184 {'title': 'Alabang Medical Clinic - Muntinlupa Branch',
185 'Details': [
186 ' ADDRESS: \n 1 National Highway, Putatan, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8861 1779']},
187 {'title': 'IMS Wellth Care, Inc.',
188 'Details': [
189 ' ADDRESS: \n 49 National Road, Putatan, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8861 1592']},
190 {'title': 'Medical Center Muntinlupa',
191 'Details': [
192 ' ADDRESS: \n National Road, Putatan, Muntinlupa \n TELEPHONE NUMBER: \n 8620162']},
193 {'title': 'Muntinlupa Doctors Clinic',
194 'Details': [
195 ' ADDRESS: \n 1 National Road, Putatan, Muntinlupa \n TELEPHONE NUMBER: \n (02) 8842 2718']},
196 {'title': 'Medcare Multi Specialty',
197 'Details': [
198 ' ADDRESS: \n 84-I, National Road, Barangay Putatan, Muntinlupa \n TELEPHONE NUMBER: \n 0922 857 4180']},
199 ]},
200 {'Category': 'Barangay SUCAT',
201 'Record': [
202 {'title': 'Sucat Health Center',
203 'Details': [
204 ' ADDRESS: \n 624 Dir. A. Bunye, Sucat, Muntinlupa \n TELEPHONE NUMBER: \n NONE']},
205 ]},
206 {'Category': 'Barangay TUNASAN',
207 'Record': [
208 {'title': 'Beato-Cauilan Hospital',
209 'Details': [
210 ' ADDRESS: \n Manila S Rd, Tunasan, Muntinlupa \n TELEPHONE NUMBER: \n +632 861-5284']},
211 ]}]
212
213 def on_start(self):
214 Clock.schedule_interval(self.update_news, 5) # every 5 seconds, show the next story
215 for category in self.card_file:
216 panel = MDExpansionPanel(icon="scr2.png", content=Content(),
217 panel_cls=MDExpansionPanelTwoLine(text=category['Category'],
218 secondary_text="Tap to view Hospitals"))
219 self.root.ids.scr_mngr.get_screen('locsearch').ids.rlist.add_widget(panel)
220 for rec in category['Record']:
221 rw = RecordLine(text=rec['title'])
222 print(rec['title'])
223 self.root.ids.scr_mngr.get_screen('locsearch').ids.rlist.children[0].content.add_widget(rw)
224
225 def showinfo(self, cat, r):
226 close_button = MDFlatButton(text="Done", on_release=self.close_dialog)
227 ingredients = self.ingredients_list(cat, r)
228 ingredients_text = ''
229 for ingredient in ingredients:
230 ingredients_text += ingredient
231 self.dialog = InformationDialog(size_hint=(0.8, 0.8), text=ingredients_text, auto_dismiss=True,
232 buttons=[close_button])
233 self.dialog.open()
234
235 def ingredients_list(self, selected_cat, selected_r):
236 self.selected_rec = selected_r
237 self.selected_category = selected_cat
238 for category in self.card_file:
239 if category['Category'] == selected_cat:
240 for rec in category['Record']:
241 if rec['title'] == selected_r:
242 return rec['Details']
243
244 def on_stop(self): # Event handler that triggers when the application has finished running
245 # Creates a json file to saved the all the items in dictionary when closing the app
246 with open('saved_list.txt', 'w') as f:
247 json.dump(self.list_items, f)
248
249 class Container(IRightBodyTouch, MDBoxLayout): # This line position widget to the right.
250 adaptive_width = True
251
252 def update_news(self, dt):
253 # this is moving through the list of stories pulled, it does not go back to the web for more content
254 # to get refresed content call self.news.get_news()
255 # Skip stories that don't have a picture and a description
256 if not self.news.headlines[self.i][1] or not self.news.headlines[self.i][2] :
257 self.i = (self.i + 1) % len(self.news.headlines)
258 self.update_news(None) # junk parameter...
259 else:
260 p = self.root.ids.nl # a sort cut to avoid writing self.root.ids.dl 3x
261 p.title = self.news.headlines[self.i][0] # The title
262 p.picture = self.news.headlines[self.i][1] # url to the picture
263 p.description = self.news.headlines[self.i][2]
264 self.i = (self.i + 1) % len(self.news.headlines)
265
266 def save_data(self):
267 conn = sql.connect('USERINFO.db')
268 cur = conn.cursor()
269 cur.execute(""" INSERT INTO information (fname,height,weight,age,heartrate) VALUES (?,?,?,?,?)""",
270 (self.root.ids.scr_mngr.get_screen('input').ids.fname.text,
271 self.root.ids.scr_mngr.get_screen('input').ids.height.text,
272 self.root.ids.scr_mngr.get_screen('input').ids.weight.text,
273 self.root.ids.scr_mngr.get_screen('input').ids.age.text,
274 self.root.ids.scr_mngr.get_screen('input').ids.heartrate.text))
275 conn.commit()
276 conn.close()
277
278 #def news(self):
279 # url = ('http://newsapi.org/v2/top-headlines?'
280 # 'country=ph&category=health&'
281 # 'apiKey=0a2a06f5a843426ca8384f89111bfe99')
282 # response = requests.get(url)
283 # print(response.json())
284 # news_json = json.loads(response.text)
285#
286 # count = 4
287#
288 # for news in news_json['articles']:
289 # if count > 0:
290 # print(str(news['title']), '\n')
291 # print(str(news['description']), "\n")
292 # print(str(news['url']), "\n")
293 # print(str(news['urlToImage']), "\n")
294 # count -= 1
295
296 def result_condition(self):
297 n = int(10000)
298
299 h = int(self.root.ids.scr_mngr.get_screen('input').ids.height.text)
300
301 w = int(self.root.ids.scr_mngr.get_screen('input').ids.weight.text)
302
303 unix = time.time()
304 date = str(datetime.datetime.fromtimestamp(unix).strftime('%Y-%m-%d %H:%M:%S'))
305 answer = (w / h / h) * n
306 print(answer)
307
308 conn = sql.connect('USERINFO.db')
309 cur = conn.cursor()
310 cur.execute(""" INSERT INTO results (NAME,RESULT,DATE_TIME) VALUES (?,?,?)""",
311 (
312 self.root.ids.scr_mngr.get_screen('input').ids.fname.text,
313 answer,
314 date
315 ))
316 conn.commit()
317 conn.close()
318 if answer <= 18.5:
319 self.root.ids.scr_mngr.current = 'underweight'
320 elif 18.6 <= answer <= 24.9:
321 self.root.ids.scr_mngr.current = 'normal'
322 elif 25.0 <= answer <= 29.9:
323 self.root.ids.scr_mngr.current = 'overweight'
324 else:
325 self.root.ids.scr_mngr.current = 'obese'
326
327 def clear_inputs(self): # set each of the inputs to an empty string
328 self.root.ids.scr_mngr.get_screen('input').ids.fname.text = ""
329 self.root.ids.scr_mngr.get_screen('input').ids.heartrate.text = ""
330 self.root.ids.scr_mngr.get_screen('input').ids.age.text = ""
331 self.root.ids.scr_mngr.get_screen('input').ids.height.text = ""
332 self.root.ids.scr_mngr.get_screen('input').ids.weight.text = ""
333
334 def info1_dialog(self):
335 close_button = MDFlatButton(text="Okay", on_release=self.close_dialog)
336 self.dialog = MDDialog(title="Details",
337 text="Hospitals listed are still operating up-to-date",
338 size_hint=(1, 1),
339 buttons=[close_button])
340 self.dialog.open()
341
342 def show_database(self):
343 conn = sql.connect('USERINFO.db')
344 cur = conn.cursor()
345 cur.execute("""
346 SELECT fname, height, weight, heartrate, RESULT, DATE_TIME
347 FROM information INNER JOIN results
348 ON information.id = results.UID
349 """)
350 output = cur.fetchall()
351 for data in output:
352 print(data)
353
354 def build(self):
355 self.theme_cls.primary_palette = "Lime"
356 self.theme_cls.theme_style = "Light" # "Light"
357 screen = Builder.load_file("main.kv")
358 return screen
359
360 def back_screen6(self, obj):
361 self.root.ids.scr_mngr.current = 'menu'
362 self.root.ids.scr_mngr.transition.direction = "right"
363
364 def show_alert_dialog(self):
365 close_button = MDFlatButton(text="Okay",
366 on_release=self.okay)
367 more_button = MDFlatButton(text="Cancel", on_press=self.close_dialog)
368
369 self.dialog = MDDialog(title="Confirmation", text="Confirm Details?",
370 size_hint=(1, 1),
371 buttons=[close_button, more_button])
372 self.dialog.open()
373
374 def result_dialog(self):
375 close_button = MDFlatButton(text="Okay", on_release=self.close_dialog)
376 self.dialog = MDDialog(title="Where did we get the Results?",
377 text="Results are Determined based on the Details Given by the User",
378 size_hint=(1, 1),
379 buttons=[close_button])
380 self.dialog.open()
381
382 def hakdog(self):
383 close_button = MDFlatButton(text="Okay", on_release=self.close_dialog)
384 self.dialog = MDDialog(title="Instructions",
385 text="Manual Heartbeat check can be used to determine if you have a normal heart rate for your age. "
386 "If height = feet/inches, Convert to Centimeter (FEET× 30.48 +INCHES× 2.54) ",
387 size_hint=(1, 1),
388 buttons=[close_button])
389 self.dialog.open()
390
391 def show_data(self, *args):
392 if self.root.ids.scr_mngr.get_screen('input').ids.fname.text == "" \
393 or self.root.ids.scr_mngr.get_screen('input').ids.height.text == "" \
394 or self.root.ids.scr_mngr.get_screen('input').ids.weight.text == "" \
395 or self.root.ids.scr_mngr.get_screen('input').ids.heartrate.text == "" \
396 or self.root.ids.scr_mngr.get_screen('input').ids.age.text == "" \
397 or self.root.ids.scr_mngr.get_screen('input').ids.heartrate.text == "":
398 close_button = MDFlatButton(text="Okay", on_release=self.close_dialog)
399 self.dialog = MDDialog(title="Invalid", text="No item added",
400 size_hint=(1, 1), buttons=[close_button])
401 self.dialog.open()
402 else:
403 self.show_alert_dialog()
404
405 def okay(self, *args):
406 print(self.root.ids.scr_mngr.get_screen('input').ids.fname.text),
407 print(self.root.ids.scr_mngr.get_screen('input').ids.height.text),
408 print(self.root.ids.scr_mngr.get_screen('input').ids.weight.text),
409 print(self.root.ids.scr_mngr.get_screen('input').ids.age.text),
410 print(self.root.ids.scr_mngr.get_screen('input').ids.heartrate.text)
411 self.save_data()
412 self.result_condition()
413 self.clear_inputs()
414 self.dialog.dismiss()
415
416 def close_dialog(self, obj):
417 self.dialog.dismiss()
418
419 def history_screen(self, obj):
420 self.root.ids.scr_mngr.current = 'history'
421 self.root.ids.scr_mngr.transition.direction = "right"
422
423 def location_screen(self, obj):
424 self.root.ids.scr_mngr.current = 'locsearch'
425 self.root.ids.scr_mngr.transition.direction = "left"
426
427 def back_screen(self, obj):
428 self.root.ids.scr_mngr.current = 'menu'
429 self.root.ids.scr_mngr.transition.direction = "left"
430
431 def back2_screen(self, obj):
432 self.root.ids.scr_mngr.current = 'input'
433 self.root.ids.scr_mngr.transition.direction = "right"
434
435 def back3_screen(self, obj):
436 self.root.ids.scr_mngr.current = 'menu'
437 self.root.ids.scr_mngr.transition.direction = "right"
438
439 def back4_screen(self, obj):
440 self.root.ids.scr_mngr.current = 'locsearch'
441 self.root.ids.scr_mngr.transition.direction = "right"
442
443
444DemoApp().run()
445-----------------------------------------------------------------------
446from kivy.network.urlrequest import UrlRequest
447from kivy.properties import ListProperty
448from kivy.event import EventDispatcher
449
450
451class News(EventDispatcher):
452 headlines = ListProperty([('Uninitialized', 'Uninitialized', 'No news is good news!')])
453
454 def get_news(self, *args):
455 url = ('http://newsapi.org/v2/top-headlines?'
456 'country=ph&category=health&'
457 'apiKey=0a2a06f5a843426ca8384f89111bfe99')
458 req = UrlRequest(url, self._got_news, on_failure=self.fail, on_error=self.fail)
459
460 def _got_news(self, req, news):
461 print(news)
462 self.headlines.clear()
463 for content in news['articles']:
464 self.headlines.append((content['title'], content['urlToImage'], content['description']))
465
466 def fail(self, instance, value):
467 print('you loose')
468 print(f'Error: {instance}, {value}')
469
470
471if __name__ == '__main__':
472 from kivy.app import App
473 from kivy.clock import Clock
474 from kivy.lang import Builder
475 from kivy.properties import StringProperty
476 from kivy.uix.screenmanager import Screen
477 from kivy.core.window import Window
478
479 import itertools
480 import pprint
481 from textwrap import dedent
482 kv = dedent("""
483 <NewsScreen>:
484 BoxLayout:
485 orientation: 'vertical'
486 Label:
487 size_hint_y: .25
488 text: root.headline
489 text_size: self.size
490 valign: 'center'
491 halign: 'center'
492 shorten: True
493 shorten_from: 'right'
494 font_size: 30
495 padding: 20,20
496 bold: True
497 GridLayout:
498 cols: 2
499 padding: 20
500 AsyncImage:
501 source: root.headline_image
502 anim_delay: .03334 # 15fps, for gif videos
503 nocache: True
504 Label:
505 padding_x: 30
506 text: root.description
507 text_size: self.size
508 font_size: 25
509 valign: 'center'
510
511 BoxLayout: # This is the root widget
512 orientation: 'vertical'
513 ScreenManager:
514 id: sm
515 NewsScreen:
516 name: 'news'
517 next: 'weather'
518 duration: 30
519 """)
520
521
522 class NewsScreen(Screen):
523 headline = StringProperty('')
524 headline_image = StringProperty('')
525 description = StringProperty('')
526
527 def __init__(self, **kwargs):
528 super().__init__(**kwargs)
529 self.app = App.get_running_app()
530 self.story = itertools.cycle(self.app.news.headlines)
531 Clock.schedule_once(self.initial_news, 5)
532 self.refresh = Clock.schedule_interval(self.news_next, 15)
533
534 def initial_news(self, *args):
535 self.headline = self.app.news.headlines[0][0] if self.app.news.headlines[0][0] else 'junk'
536 self.headline_image = self.app.news.headlines[0][1] if self.app.news.headlines[0][1] else 'junk'
537 self.description = self.app.news.headlines[0][2] if self.app.news.headlines[0][2] else 'No Description'
538 print(self.headline)
539
540 def news_next(self, *args):
541 n = next(self.story)
542 self.headline = n[0]
543 self.headline_image = n[1] if n[1] is not None else ''
544 self.description = n[2]
545
546 # def on_pre_enter(self, *args):
547 # self.refresh() # start the news refresh schedule
548 #
549 # def on_leave(self, *args):
550 # self.refresh.cancel() # cancel the schedule when we leave the screen
551
552
553 class TestNewsApp(App):
554 news = News()
555
556 def build(self):
557 Window.size = 1500, 303
558 Window.top = 100
559 Window.left = 10
560 return Builder.load_string(kv)
561
562 def on_start(self):
563 self.news.get_news()
564 Clock.schedule_once(self.print_news, 5) # wait for site..
565 print('waiting 5 seconds...')
566
567 def print_news(self, dt):
568 pp = pprint.PrettyPrinter(width=80, compact=True)
569 pp.pprint(self.news.headlines)
570
571
572 TestNewsApp().run()
573------------------------------------------------------------------
574Screen:
575 ScreenManager:
576 id:scr_mngr
577 MainMenuScreen:
578 name:"menu"
579 InputScreen:
580 name:"input"
581 RestingHeartRateScreen:
582 name:"heartrate"
583 ResultObeseScreen:
584 name:"obese"
585 ResultUnderweightScreen:
586 name:"underweight"
587 ResultOverweightScreen:
588 name:"overweight"
589 ResultNormalScreen:
590 name:"normal"
591 LocationSearchScreen:
592 name:"locsearch"
593 LocationResultScreen:
594 name:"locresult"
595 HistoryScreen:
596 name:"history"
597
598<MainMenuScreen>
599 MDNavigationLayout:
600 ScreenManager:
601 Screen:
602 BoxLayout:
603 orientation:'vertical
604 NewsLayout:
605 id: nl # used to write properties in update news
606
607 Label:
608 size_hint_y: None
609 height: 100
610 text: root.title
611 text_size: self.size
612 valign: 'center'
613 BoxLayout:
614 AsyncImage:
615 source: root.picture
616 Label:
617 text_size: self.size
618 valign: 'center'
619 text: root.description
620
621 MDToolbar:
622 title:' MD 24/7'
623 elevation:10
624 Widget:
625
626 MDBottomAppBar:
627 MDToolbar:
628 icon: "account"
629 type: "bottom"
630 on_action_button:
631 root.manager.current='input'
632 root.manager.transition.direction = "right"
633 left_action_items:[["history",lambda x: app.history_screen("history")]]
634 right_action_items:[["google-earth",lambda x: app.location_screen("locsearch")]]
635
636<InputScreen>
637 on_pre_enter: app.clear_inputs()
638 id:information
639 BoxLayout:
640 orientation: 'vertical'
641 MDToolbar:
642 title:'Input Details'
643 elevation:10
644 left_action_items:[["backspace",lambda x:app.back_screen("menu")]]
645 right_action_items:[["head-question",lambda x:app.hakdog()]]
646
647 Widget:
648 MDTextField:
649 id:fname
650 required: True
651 hint_text: "Full name"
652 icon_right:"account"
653 pos_hint: {'center_x': 0.5}
654 size_hint_x: None
655 width: '250dp'
656 helper_text:"Please enter your Registered Name"
657 helper_text_mode:"persistent"
658 Widget:
659 height: 35
660
661 MDTextField:
662 id:height
663 required: True
664 hint_text: "Height"
665 icon_right:"human-male-height"
666 pos_hint: {'center_x': 0.5}
667 size_hint_x: None
668 width: '250dp'
669 helper_text:"Must be in centimeters"
670 helper_text_mode:"persistent"
671 Widget:
672 height:35
673
674 MDTextField:
675 id:weight
676 required: True
677 hint_text: "Weight"
678 icon_right:"weight-kilogram"
679 pos_hint: {'center_x': 0.5}
680 size_hint_x: None
681 width: '250dp'
682 helper_text:"Must be in Kilogram"
683 helper_text_mode:"persistent"
684 Widget:
685 height:35
686
687 MDTextField:
688 id:age
689 hint_text: "Age"
690 required: True
691 icon_right:"cake"
692 pos_hint: {'center_x': 0.5}
693 size_hint_x: None
694 width: '250dp'
695 helper_text:"please enter your age"
696 helper_text_mode:"persistent"
697 Widget:
698 height: 35
699
700 MDTextField:
701 id:heartrate
702 required: True
703 hint_text: "Heartrate"
704 icon_right:"heart-pulse"
705 pos_hint: {'center_x': 0.5}
706 size_hint_x: None
707 width: '250dp'
708 helper_text:"Count the beat on your palm for 60 seconds"
709 helper_text_mode:"persistent"
710 Widget:
711 size_hint_y: None
712
713 MDScreen:
714 MDRectangleFlatButton:
715 mode: "rectangle"
716 text: 'Confirm'
717 pos_hint: {'center_x':0.5, 'center_y':0.8}
718 on_press :
719 app.show_data()
720
721 Widget:
722 size_hint_x: None
723
724<ResultObeseScreen>
725 BoxLayout:
726 orientation: 'vertical'
727 MDToolbar:
728 title:'Result: OBESE'
729 elevation:10
730 right_action_items:[["head-question",lambda x:app.result_dialog()]]
731 Widget:
732
733 MDLabel:
734 text: " People with obesity have increased risk of cardiovascular disease,type 2 diabetes, high blood pressure, and other health conditions. Waist-to-hip ratio, waist-to-height ratio, and body fat percentage measurements can provide a more complete picture of any health risks. A person should consult with their healthcare provider and consider making lifestyle changes through healthy eating and fitness to improve their health indicators. \n TIPS: \n *Change your diet. \n *Consider adding physical activity \n *Medication \n *Consume less “bad” fat and more “good” fat. \n *Consume less processed and sugary foods. \n *Eat more servings of vegetables and fruits \n *Eat plenty of dietary fiber. \n *limit your vices (drinking,smoking,etc)"
735 halign: "left"
736
737 Widget:
738
739 MDScreen:
740 MDRectangleFlatButton:
741 mode: "rectangle"
742 text: 'Go to Main Menu'
743 pos_hint: {'center_x':0.5, 'center_y':0.8}
744 on_press : root.manager.current='menu'
745
746<ResultNormalScreen>
747 BoxLayout:
748 orientation: 'vertical'
749 MDToolbar:
750 title:'Result: NORMAL WEIGHT'
751 elevation:10
752 right_action_items:[["head-question",lambda x:app.result_dialog()]]
753 Widget:
754
755 MDLabel:
756 text :" Maintaining a healthy weight may lower the risk of developing certain health conditions, including cardiovascular disease and type 2 diabetes. Waist-to-hip ratio, waist-to-height ratio, and body fat percentage measurements can provide a more complete picture of any health risks. \n TIPS: \n *Limit what you eat \n *exercise \n *sleep 7-8 hours a day \n *maintain a consistent sleeping routine \n *consider eating more healthy foods \n *limit your vices (drinking,smoking,etc)"
757 halign: "left"
758
759 Widget:
760
761 MDScreen:
762 MDRectangleFlatButton:
763 mode: "rectangle"
764 text: 'Go to Main Menu'
765 pos_hint: {'center_x':0.5, 'center_y':0.8}
766 on_press : root.manager.current='menu'
767
768<ResultOverweightScreen>
769 BoxLayout:
770 orientation: 'vertical'
771 MDToolbar:
772 title:'Result: OVERWEIGHT'
773 elevation:10
774 right_action_items:[["head-question",lambda x:app.result_dialog()]]
775 Widget:
776
777 MDLabel:
778 text: " Being overweight may increase the risk of certain health conditions, including cardiovascular disease, high blood pressure, and type 2 diabetes. Waist-to-hip ratio, waist-to-height ratio, and body fat percentage measurements can provide a more complete picture of any health risks. A person should consult with their healthcare provider and consider making lifestyle changes through healthy eating and fitness to improve their health indicators.Being overweight or fat is having more body fat than is optimally healthy \n TIPS: \n *Eat a high protein breakfast. \n *Avoid sugary drinks and fruit juice \n *Drink water before meals. \n *Choose weight-loss-friendly foods. \n *Eat soluble fiber. \n *Drink coffee or tea. \n *Base your diet on whole foods. \n *Eat slowly. \n *limit your vices (drinking,smoking,etc)"
779 halign: "left"
780
781 Widget:
782
783 MDScreen:
784 MDRectangleFlatButton:
785 mode: "rectangle"
786 text: 'Go to Main Menu'
787 pos_hint: {'center_x':0.5, 'center_y':0.8}
788 on_press : root.manager.current='menu'
789
790<ResultUnderweightScreen>
791 BoxLayout:
792 orientation: 'vertical'
793 MDToolbar:
794 title:'Result: UNDERWEIGHT'
795 elevation:10
796 right_action_items:[["head-question",lambda x:app.result_dialog()]]
797 Widget:
798
799 MDLabel:
800 text: " Being underweight may pose certain health risks, including nutrient deficiencies and hormonal changes. Waist-to-hip ratio, waist-to-height ratio, and body fat percentage measurements can provide a more complete picture of any health risks. A person should consult with their healthcare provider and consider making lifestyle changes through healthy eating and fitness to improve their health indicators.Being underweight can cause health problems. An underweight person is a person whose body weight is considered too low to be healthy /n TIPS: /n *eat more frequently /n *choose nutrient-rich foods /n *watch what you eat and drink /n *exercise /n *limit your vices (drinking,smoking,etc)"
801 halign: "left"
802
803 Widget:
804
805 MDScreen:
806 MDRectangleFlatButton:
807 mode: "rectangle"
808 text: 'Go to Main Menu'
809 pos_hint: {'center_x':0.5, 'center_y':0.8}
810 on_press : root.manager.current='menu'
811
812<LocationSearchScreen>
813 BoxLayout:
814 orientation: 'vertical'
815 MDToolbar:
816 title:'Hospital Searcher'
817 elevation:10
818 left_action_items:[["backspace",lambda x:app.back_screen6("menu")]]
819 right_action_items:[["head-question",lambda x:app.info1_dialog()]]
820
821 ScrollView:
822 MDList:
823 id: rlist
824<RecordLine>:
825 adaptive_height: True
826 OneLineListItem:
827 text: root.text
828 on_release: app.showinfo(root.parent.parent.panel_cls.text, self.text)
829
830<InformationDialog>:
831 title: "Details:"
832
833<OneLineAvatarIconListItem>: # The list widget
834 id: icnlst
835 IconLeftWidget:
836 icon: "clipboard"
837 RightCheckbox:
838 id: cb
839 Container:
840 MDIconButton:
841 icon:'close-circle-outline'
842 on_release: app.remove_one_item(root.text)
843
844<HistoryScreen>
845 MDFloatingActionButton:
846 icon: "magnify"
847 md_bg_color: app.theme_cls.primary_color
848 pos_hint: {"center_x": .8, "center_y": .1}
849 user_font_size: "25sp"
850 on_release:
851 app.show_database()
852
853 MDTextField:
854 id: inp
855 hint_text: 'Enter Full Name'
856 size_hint_x: None
857 pos_hint: {"center_x": .4, "center_y": .1}
858 width: '170dp'
859
860 MDCard:
861 size_hint: None, None
862 size: "280dp", "280dp"
863 pos_hint: {"center_x": .5, "center_y": .5}
864 orientation: "vertical"
865
866 ScrollView:
867 MDList:
868 id: list
869
870 MDToolbar:
871 id: toolbar
872 pos_hint: {"top": 1}
873 elevation: 6
874 title: "Check History"
875 left_action_items:[["backspace",lambda x:app.back_screen("menu")]]