@mikael and @cvp Thanks for the help as always. I ended up using the @cvp suggestion. I’m redoing the personal protective equipment app using the ui module instead of scene. Coming along well.
I hve an issue with displaying hyperlinks in a text view and getting the ui.path.rounde_rect to draw to the screen I a for loop.
import console
import ui
from ppeasy_text import text
app_title = 'PPEasy'
app_title_font = 'Didot'
btn_font = 'Didot'
text_font = '<System>'
text_color = '1D3557'
bg_color = 'CAF0F8'
btn_border_color = '0077B6'
btn_color = 'CAF0F8'
btn_shadow=('gray', 0, 7, 2)
btn_corner_radius = 10
screen_size = ui.get_window_size()
links ='\n\nwww.cdv.gov \n\nwww.fda.gov \n\nwww.coronavirus.gov \n\nwww.covid19.healthdata.org'
v = ui.View()
v.background_color=bg_color
def make_title(text):
title = ui.Label()
title.font= app_title_font, 30
title.text = text
title.alignment= ui.ALIGN_CENTER
title.frame=(screen_size.w * 0.10, screen_size.h * 0.05, screen_size.w * 0.75, screen_size.h * 0.05)
return title
def make_button(title, locale, text_param, image_param,dwell_time_param, desc_param, action=None):
btn= ui.Button()
btn.background_color='white'
btn.title=title
btn.font=(btn_font, 18)
btn.background_color=bg_color
btn.tint_color='black'
btn.border_width=2
btn.border_color='black'
btn.frame=(screen_size.w * 0.15, screen_size.h * locale, screen_size.w * 0.7, screen_size.h * 0.07)
btn.corner_radius= btn_corner_radius
btn.text_param = text_param
btn.image_param = image_param
btn.dwell_time_param = dwell_time_param
btn.desc_param = desc_param
btn.action = action
# v.add_subview(btn_1)
return btn
def page_info(text, image, dwell_time, desc):
v = ui.View()
v.background_color=bg_color
title= make_title(text)
for x, y in (screen_size.w/2, screen_size.h * 0.8), (screen_size.w/2, screen_size.h * 0.4), (screen_size.w/2, screen_size.h * 0.1):
line = ui.Path()
line = ui.Path.rounded_rect(x, y, screen_size.w * 0.8, 0, 50)
line.line_width=3
#display.add_subview(line)
img = ui.ImageView()
img.image = ui.Image.named(image)
img.frame=(screen_size.w * 0.15, screen_size.h * 0.15, 300, 300)
img.content_mode = ui.CONTENT_SCALE_ASPECT_FIT
dwell = ui.Label()
dwell.font= app_title_font, 25
dwell.text = dwell_time
dwell.alignment= ui.ALIGN_CENTER
dwell.frame=screen_size.w * 0.10, screen_size.h * 0.45, screen_size.w * 0.75, screen_size.h * 0.05
description = ui.TextView()
description.editable=False
description.scroll_enabled=True
description.auto_content_inset=True
description.background_color=bg_color
description.alignment= ui.ALIGN_LEFT
description.number_of_lines=0
description.line_break_mode=ui.LB_CHAR_WRAP
description.font=(text_font, 17)
description.frame=(screen_size.w * 0.12, screen_size.h * 0.60, screen_size.w * 0.75, screen_size.h * 0.60)
description.text=desc
v.add_subview(title)
v.add_subview(img)
v.add_subview(dwell)
v.add_subview(description)
v.present('sheet', hide_title_bar=True)
def mask_page(sender):
v = ui.View()
v.background_color=bg_color
title=make_title('mask')
level_1_btn = make_button('Level 1', 0.12, 'Level 1', 'Level1Mask.PNG', '', level_1_desc, info_page)
level_3_btn = make_button('Level 3', 0.22, 'Level 3', 'Level3Mask.PNG', '', level_3_desc, info_page)
k_n95_btn = make_button('K-N95', 0.32, 'K-N95', 'Kn95Mask.PNG', '', k_n95_desc, info_page)
n95_btn = make_button('N95', 0.42, 'N95', 'N95Mask.PNG', '', n95_desc, info_page)
papr_btn = make_button('Papr', 0.52, 'Papr', 'PaprMask.PNG', '', papr_desc, info_page)
v.add_subview(title)
v.add_subview(level_1_btn)
v.add_subview(level_3_btn)
v.add_subview(k_n95_btn)
v.add_subview(n95_btn)
v.add_subview(papr_btn)
v.present('sheet', hide_title_bar=True)
def info_page(sender):
page_info(sender.text_param, sender.image_param, sender.dwell_time_param, sender.desc_param)
def gowns_page(sender):
v = ui.View()
v.background_color=bg_color
title= make_title('Gowns')
cloth_btn = make_button('Cloth', 0.12, 'Cloth', 'ClothGown.PNG', '', cloth_desc, info_page)
plastic_btn = make_button('Plastic', 0.22, 'Plastic', 'PlasticGown.PNG', '', plastic_desc, info_page)
v.add_subview(title)
v.add_subview(cloth_btn)
v.add_subview(plastic_btn)
v.present('sheet', hide_title_bar=True)
def wipes_page(sender):
v = ui.View()
v.background_color=bg_color
v.present('sheet', hide_title_bar=True)
def faq_page(sender):
v = ui.View()
v.background_color=bg_color
title = ui.Label()
title.font= text_font, 25
title.text = "FAQ"
title.alignment= ui.ALIGN_CENTER
title.frame=screen_size.w * 0.1, screen_size.h * 0.02, screen_size.w * 0.75, screen_size.h * 0.05
tv = ui.TextView()
tv.editable=False
tv.scroll_enabled=True
tv.auto_content_inset=True
tv.background_color=bg_color
tv.alignment= ui.ALIGN_LEFT
tv.number_of_lines= 0
tv.line_break_mode = ui.LB_CHAR_WRAP
tv.font= text_font, 17
tv.frame= screen_size.w * 0.07, screen_size.h * 0.08, screen_size.w * 0.87, screen_size.h * 0.85
tv.text = "Q. What is the difference between a K-N96 and a N95? \n\nA. Both products are said to filter 95 percent of aerosol particulates. K-N95 respirators differ from N95 respirators because they meet the Chinese standard but are not regulated by U.S. agencies. \n\nQ. Do mask really work? \n\nA. Yes. It stops the transmission of saliva and mucus from person to person "
v.add_subview(title)
v.add_subview(tv)
v.present('sheet', hide_title_bar=True)
def dd_page(sender):
v = ui.View()
v.background_color=bg_color
title = ui.Label()
title.font= text_font, 25
title.text = "Dos and Don'ts"
title.alignment= ui.ALIGN_CENTER
title.frame=screen_size.w * 0.1, screen_size.h * 0.02, screen_size.w * 0.75, screen_size.h * 0.05
tv = ui.TextView()
tv.editable=False
tv.scroll_enabled=True
tv.auto_content_inset=True
tv.background_color=bg_color
tv.alignment= ui.ALIGN_LEFT
tv.number_of_lines= 0
tv.line_break_mode = ui.LB_CHAR_WRAP
tv.font= text_font, 17
tv.frame= screen_size.w * 0.07, screen_size.h* 0.08, screen_size.w * 0.85, screen_size.h * 0.85
tv.text = "DO wear your cask correctly. Cover you mouth and nose. \nDON'T improperly wear your mask. Make sure you mouth and nose is covered. \n\nDO keep you mask clean. \nDON'T touch mask with your hands. \n\nDO change your mask regulary. \nDON'T wear a dirty mask' \n\nDO wear your mask while talking. \nDON'T remove your mask to talk. \n\nDO wear masks that fit well and trap your breath. \nDON'T ware masks with vents. They allow your breath to escape and spread to others. \n\nDo keep 6 feet apart when out in public even while wearing a mask. \nDON'T beark social distancing even if your wearing a mask. \n\nDO"
v.add_subview(title)
v.add_subview(tv)
v.present(hide_title_bar=True)
def covid_page(sender):
v= ui.View()
v.background_color=bg_color
title = ui.Label()
title.font= app_title_font, 25
title.text = 'Covid Information'
title.alignment= ui.ALIGN_CENTER
title.frame=screen_size.w * 0.1, screen_size.h * 0.02, screen_size.w * 0.75, screen_size.h * 0.05
tv = ui.TextView()
tv.editable=False
tv.scroll_enabled=True
tv.background_color=bg_color
tv.alignment= ui.ALIGN_LEFT
tv.number_of_lines= 0
tv.line_break_mode = ui.LB_CHAR_WRAP
tv.font= app_title_font, 17
tv.frame= screen_size.w * 0.07, screen_size.h * 0.08, screen_size.w * 0.87, screen_size.h * 0.85
tv.text = 'COVID-19 is caused by a coronavirus called SARS-CoV-2. Older adults and people who have severe underlying medical conditions like heart or lung disease or diabetes seem to be at higher risk for developing more serious complications from COVID-19 illness. \n\nSymptoms may appear 2-14 days after exposure to the virus. People with these symptoms may have COVID-19:\n\n•Fever or chills\n•Cough\n•Shortness of breath or difficulty breathing\n•Fatigue\n•Muscle or body aches\n•Headache\n•New loss of taste or smell\n•Sore throat\n•Congestion or runny nose\n•Nausea or vomiting\n•Diarrhea \n\nEmergency warning signs. If someone is showing any of these signs, seek emergency medical care immediately:\n\n•Trouble breathing\n•Persistent pain or pressure in the chest\n•New confusion\n•Inability to wake or stay awake\n•Bluish lips or face \n\nCOVID-19 most commonly spreads during close contact. People who are physically near (within 6 feet) a person with COVID-19 or have direct contact with that person are at greatest risk of infection. \n\nWhen people with COVID-19 cough, sneeze, sing, talk, or breathe they produce respiratory droplets. These droplets can range in size from larger droplets (some of which are visible) to smaller droplets. Small droplets can also form particles when they dry very quickly in the airstream. \n\nInfections occur mainly through exposure to respiratory droplets when a person is in close contact with someone who has COVID-19. Respiratory droplets cause infection when they are inhaled or deposited on mucous membranes, such as those that line the inside of the nose and mouth. \n\nAs the respiratory droplets travel further from the person with COVID-19, the concentration of these droplets decreases. Larger droplets fall out of the air due to gravity. Smaller droplets and particles spread apart in the air.With passing time, the amount of infectious virus in respiratory droplets also decreases.'
v.add_subview(title)
v.add_subview(tv)
v.present(hide_title_bar=True)
def links_page(sender):
v = ui.View()
v.background_color=bg_color
v= ui.View()
v.background_color=bg_color
title = ui.Label()
title.font= text_font, 25
title.text = "Links"
title.alignment= ui.ALIGN_CENTER
title.frame=screen_size.w * 0.1, screen_size.h * 0.02, screen_size.w * 0.75, screen_size.h * 0.05
tv = ui.TextView()
tv.editable=False
tv.scroll_enabled=True
tv.auto_content_inset=True
tv.background_color=bg_color
tv.alignment= ui.ALIGN_CENTER
tv.number_of_lines= 0
tv.line_break_mode = ui.LB_CHAR_WRAP
tv.font= text_font, 22
tv.frame= screen_size.w * 0.07, screen_size.h * 0.08, screen_size.w * 0.87, screen_size.h * 0.85
tv.text ='https://www.who.int/'
v.add_subview(title)
v.add_subview(tv)
v.present('sheet', hide_title_bar=True)
title = make_title(app_title)
mask_btn = make_button('Mask', 0.12, '', '', '', '', mask_page)
shield_btn = make_button('Shield', 0.22, 'Face Shield', 'FaceShield.JPG', '',fs_desc, info_page)
gowns_btn = make_button('Gowns', 0.32,'', '', '', '', gowns_page)
wipes_btn = make_button('Wipes', 0.42, '', '', '', '', wipes_page)
faq_btn = make_button('FAQ', 0.52, '','','','',faq_page)
dd_btn = make_button('Dos/Donts', 0.62, '', '', '', '', dd_page)
covid_btn = make_button('Covid Info', 0.72, '', '', '', '', covid_page)
links_btn = make_button('Links', 0.82, '', '', '', '', links_page)
v.add_subview(title)
v.add_subview(mask_btn)
v.add_subview(shield_btn)
v.add_subview(gowns_btn)
v.add_subview(wipes_btn)
v.add_subview(faq_btn)
v.add_subview(dd_btn)
v.add_subview(covid_btn)
v.add_subview(links_btn)
v.present('full_screen', orientations='portrait', hide_title_bar=True)
I also have Trouble importing text from another file. I tried to set it up like the brick breaker levels and colors example but it’s not working.