Forum Archive

Personal Protective Equipment App

resserone13

https://github.com/resserone13/PPEasy

@cvp I put together a simple app to help explain the difference in personal protective equipment. I’m still up dating the faq and dos and dont’s page. I’m going to use label nodes for now but want to make a for loop to display all the text in the faq page. I will also be updating the rest of the info to be more in-depth but the basic app is done. Any advice or help is welcomed.

cvp

@resserone13 I guess this post is addressed to me personally because of my rather advanced age (😢 but also 😂)
Seriously, well done, but, if you permit, your code contains a lot of repetitive parts and these could be easily generalized... I'll check a little bit, but as usual, @ccc and @mikael are far away better than me for this kind of task.
One more time, good and also nice job.

resserone13

@cvp you are right. A lot of repetitive code. I don’t know how to make functions outside of the class Because they rely on the scene module. So when I make the function outside of the classes it says things have not been defined. Once I grasp that concept I should progress quite a bit. I mentioned you because you said you would like to help and be involved. All today I updated a lot of the text to provide better descriptions. Also not sure how I should work on the project once It’s posted to github. how do I keep all the changes im making on my phone updated to the github? Thanks for yr help and interest.

cvp

@resserone13 example: you can replace your 4 scenes Oxyvir, Sani, Ammonia, Bleach by only one

        if touch.location in self.oxy_box.frame:
            #self.present_modal_scene(Oxy())    
            sc = Any()
            sc.title_param = 'Oxyvir'
            sc.image_param = 'OxyvirWipes.PNG'
            sc.text_param  = 'Oxivir is recommended for general \ndisinfecting. The active ingredient \nhydrogen peroxide. It does NOT \nkill the bacteria that causes C-Diff \nand should never be used to \ndisinfect anything that may be \ncontaminated with C-Diff.'
            self.present_modal_scene(sc)

        if touch.location in self.sani_box.frame:
            #self.present_modal_scene(Sani())
            sc = Any()
            sc.title_param = 'Sani (Alcohol)'
            sc.image_param = 'SaniWipes.PNG'
            sc.text_param  = 'Sani is recommended for general \ndisinfecting. The active ingredient \nis Alcohol. It does NOT kill the \nbacteria that causes C-Diff and \nshould never be used to \ndisinfect anything that may be \ncontaminated nwith C-Diff.'
            self.present_modal_scene(sc)

        if touch.location in self.bleach_box.frame:
            #self.present_modal_scene(Bleach()) 
            sc = Any()
            sc.title_param = 'Bleach'
            sc.image_param = 'BleachWipes.PNG'
            sc.text_param  = 'Bleach is a Sporicidal disinfectant. \nThe active ingredient is Sodium \nhypochlorite. Bleach kills the \nbacteria that causes C-Diff \nand should always be used to \ndisinfect anything that may be \ncontaminated with C-Diff.'
            self.present_modal_scene(sc)


        if touch.location in self.ammonia_box.frame:
            #self.present_modal_scene(Ammonia())    
            sc = Any()
            sc.title_param = 'Ammonia'
            sc.image_param = 'AmmoniaWipes.PNG'
            sc.text_param  = 'Ammonia is recommended for \ncleaning sensitive electiral devices. \nThe active ingredient Ammonia. \nIt does NOT kill the bacteria that \ncauses C-Diff and should never \nbe used to disinfect anything that \nmay be contaminated with C-Diff.'
            self.present_modal_scene(sc)

class Any(Scene):
    def setup(self):
        self.bg_color = SpriteNode(color=bg_color, size=self.size, position=(self.size.w/2, self.size.h/2), parent=self)    

        self.root_node = Node(parent=self)  

        for i in (self.size.w/2, self.size.h * 0.8), (self.size.w/2, self.size.h * 0.4), (self.size.w/2, self.size.h * 0.1):
            self.text_line = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.8, 0, 20))
            self.text_line.position=i
            self.text_line.fill_color=btn_color
            self.text_line.line_width=4
            self.text_line.stroke_color=text_color
            self.add_child(self.text_line)

        self.title = LabelNode(self.title_param, (app_title_font, 30), position=(self.size.w/2, self.size.h * 0.85), color=text_color, parent=self)

        self.image = SpriteNode(self.image_param, position=(self.size.w/2, self.size.h * 0.60), scale=0.50, parent=self)

        self.txt = text

        self.discription = LabelNode(f'{self.text_param}', (text_font, 20), position=(self.size.w/2, self.size.h * 0.25), color=text_color, parent=self)    

        self.back = SpriteNode('iob:ios7_redo_32', position=(self.size.w * 0.87, self.size.h * 0.95), parent=self)      

    def touch_began(self, touch):
        if touch.location in self.back.frame:
            self.dismiss_modal_scene()  
cvp

@resserone13 said:

Also not sure how I should work on the project once It’s posted to github. how do I keep all the changes im making on my phone updated to the github

For that also, @ccc and @mikael are the best ones

cvp

@resserone13 if, in my new class Any, you do

        if self.image_param != '':
            self.image = SpriteNode(self.image_param, position=(self.size.w/2, self.size.h * 0.60), scale=0.50, parent=self)

You can even use it also for FAQ and thus remove your FAQ class

        if touch.location in self.faq_box.frame:
            #self.present_modal_scene(Faq())        
            sc = Any()
            sc.title_param = 'FAQ'
            sc.image_param = ''
            sc.text_param  = 'On March 13, 2020, the CDC \nupdated their recommendations for \nEPA-registered disinfectants to \nrefer to the EPA website \nfor EPA’s List N entitled Products \nwith Emerging Viral Pathogens and \nHuman Coronavirus claims for use against \nSARS-CoV-2 (COVID-19). \nSuper Sani-Cloth® Germicidal \nDisposable Wipes ,can be found on List N.'
            self.present_modal_scene(sc)
resserone13

@cvp I believe the any class should work for the majority of the scenes. For the faq page I was thinking of a for loop that prints out label nodes. I was going to feed it a list of questions and a list of answers. I was working on one but he kept printing everything on top of each other rather than printing down the page one after another.

cvp

@resserone13 you can also use it for ClothGown and PlasticGown, but I let you do it for PlasticGown

        if touch.location in self.cloth_box.frame:
            #self.present_modal_scene(ClothGown())
            sc = Any()
            sc.title_param = 'Cloth'
            sc.image_param = 'ClothGown.PNG'
            sc.text_param  = 'This is a cloth gown. \nIt must be worn while \nproviding care to patients \nwho are in isolation. \n\nIts NOT recommended to \nwear a cloth gown while \ncaring for patients \nwith C-diff or TB.'
            self.present_modal_scene(sc)
cvp

@resserone13 said:

I believe the any class should work for the majority of the scenes

Sorry, I was busy to write my post about ClothGown and did not see your last post

cvp

@resserone13 Normally, Scene is made for animation or games and I am not used to using it. Personally, I would have used ui.View.

resserone13

@cvp no worries. The good thing is I can see what’s going on in the code you recommended. Which means I should be able to implement it and learn from it. I see how you’re using parameters and they get a sign different things depending on which button is touched.

cvp

@resserone13 said:

. I see how you’re using parameters

That is also a reason why I would prefer to use ui.View because with it, you can really pass parameters for its creation (Init) and I don't know if it is possible with a Scene, and thus how.

resserone13

@cvp i can’t wait to use ui with scene. I’ve been working with scene recently and knew how to do it with scene so I choose scene. I’ve tried ui before but did take to it as well as I have scene.

resserone13

@cvp I believe examples in the Pythonista app uses init with the scene module. Init is another concept I partially grasp. I was working on another app for keeping track of dirty beds in the hospital which basically was just a bunch of classes that all had inits. I know where they go and how to set them but that about all.

cvp

@resserone13 Ui would be easier for your FAQ list by using a ui.TableView which is scrollable of your list becomes bigger than an unique page

resserone13

@cvp that’s actually what I was looking for. When I was trying UI before I had a bunch of questions and by the time I try to do a scroll view or any tables I didn’t understand what the data source was.?

cvp

@resserone13 I can't do shorter than this 😀

import ui
tv = ui.TableView()
items = ['faq 1', 'faq 2']
tv.data_source = ui.ListDataSource(items=items)
tv.present()
resserone13

@cvp I’m gonna try to update the app to use any() scene. I’ll keep you updated. Next I’m will work on some ui stuff and try to mix the 2. Thanks for everything.

cvp

@resserone13 a very quick and very dirty example with ui (keep only the good part 😀)

import ui

text_font = 'Arial'
text_color = 'black'
bg_color = '#9cbeff'

mv = ui.View()
mv.name = 'Test for @resserone13'
mv.bg_color = bg_color
w,h = ui.get_screen_size()

w_b = w*0.65
h_b = h*0.07

def sv(title,desc,image=None,items=None):
    sv = ui.View()
    sv.name = title
    sv.bg_color = bg_color
    y = 10

    if image: 
        iv = ui.ImageView()
        iv.image = ui.Image.named(image)
        wi,hi = iv.image.size
        sc = min(w/wi,h/hi)
        wi = sc * wi/2
        hi = sc * hi/2
        iv.frame = ((w-wi)/2,y,wi,hi)
        iv.content_mode = ui.CONTENT_SCALE_ASPECT_FIT
        sv.add_subview(iv)
        y += hi + 10

    ld = ui.Label()
    ld.frame = (10,y,w-20,400)
    ld.alignment = ui.ALIGN_CENTER
    ld.font = (text_font,25)
    ld.text = desc
    ldo = ObjCInstance(ld)
    ldo.numberOfLines = 0
    sv.add_subview(ld)
    y += ld.height + 10

    if items:
        tv = ui.TableView()
        tv.row_height = 32
        ht = min(len(items)*tv.row_height,h - y - 100)
        tv.frame = (10,y,w-20,ht)
        tv.data_source = ui.ListDataSource(items=items)
        sv.add_subview(tv)  
        y += ht + 10

    sv.present('fullscreen')
    sv.wait_modal()

def set_b(x_c,y_c,title,desc,image=None,items=None):
    b = ui.Button()
    b.title = title
    b.name = title
    b.font = (text_font, 30)
    b.tint_color = text_color
    x_b = x_c - w_b/2
    y_b = y_c - h_b/2
    b.frame = (x_b,y_b,w_b,h_b)
    b.border_width = 3
    b.border_color = 'white'
    b.corner_radius = 2
    b.infos  = (desc,image,items)
    def b_action(sender):
        sv(sender.title, sender.infos[0], image=sender.infos[1], items=sender.infos[2])
    b.action = b_action
    mv.add_subview(b)

x_c, y_c = w/2, h * 0.45
set_b(x_c,y_c,'Cloth','This is a cloth gown. \nIt must be worn while \nproviding care to patients \nwho are in isolation. \n\nIts NOT recommended to \nwear a cloth gown while \ncaring for patients \nwith C-diff or TB.', image='ClothGown.PNG')

x_c, y_c = w/2, h * 0.55
set_b(x_c,y_c,'Plastic','This is a plastic gown. \nIt must be worn while \nproviding care to C-Diff \npatients. \n\nIts is recommended to \nwear a plastic gown while \nproviding care to patients \nwith TB.', image='PlasticGown.PNG')

x_c, y_c = w/2, h * 0.65
items = []
for i in range(30):
    items.append('faq n°'+str(i+1))
set_b(x_c,y_c,'FAQ','On March 13, 2020, the CDC \nupdated their recommendations for \nEPA-registered disinfectants to \nrefer to the EPA website \nfor EPA’s List N entitled Products \nwith Emerging Viral Pathogens and \nHuman Coronavirus claims for use against \nSARS-CoV-2 (COVID-19). \nSuper Sani-Cloth® Germicidal \nDisposable Wipes ,can be found on List N.', items=items)

mv.present('fullscreen')
resserone13

@cvp I’ve updated the program to use the Any() class and the program went from 730 lines to 430 lines of code. I working on the tableview for the faqs page and the dos and donts! Ima work on the tableview a bit before I ask for help. Thanks.

ccc

Is the repo up to date?

resserone13

@ccc not yet. Here’s the code.


from scene import *
import sound
import random
import math
import ui


A = Action
app_title = 'PPEasy'
app_title_font = 'Avenir Next Condensed Bold'
text_font = 'Arial'
text_color = 'black'
bg_color = '#9cbeff'
btn_border_color = 'white'
border_color = 'gray'
btn_color = '#9cbeff'
btn_shadow=('gray', 0, 7, 2)
border_radias = 30

class  Intro(Scene):
    def setup(self):

        self.intro_bg = SpriteNode(position=self.size/2, color=bg_color, size=self.size, alpha=1, parent=self)

        self.app_title = LabelNode('PPEasy', font=(app_title_font, 50), position=(self.size/2), color=text_color, parent=self)

        self.text = 'Thanks for being safe'

        self.discription = LabelNode(f'{self.text}', (text_font, 25), position=(self.size.w/2, self.size.h * 0.25), color=text_color, parent=self)      

        self.run_action(A.sequence(A.wait(3), A.call(self.dismiss_scene)))


    def dismiss_scene(self):
        self.dismiss_modal_scene()      

class MyScene (Scene):
    def setup(self):

        self.main_node = Node(parent=self)

        self.background_color = bg_color

        self.mask_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.mask_box.position=(self.size.w/2, self.size.h * 0.79)
        self.mask_box.fill_color=btn_color
        self.mask_box.line_width=4
        self.mask_box.stroke_color=btn_border_color
        self.mask_box.shadow=btn_shadow
        self.add_child(self.mask_box)   

        self.sheild_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.sheild_box.position=(self.size.w/2, self.size.h * 0.69)
        self.sheild_box.fill_color=btn_color
        self.sheild_box.line_width=4
        self.sheild_box.stroke_color=btn_border_color
        self.sheild_box.shadow=btn_shadow       
        self.add_child(self.sheild_box)

        self.gowns_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.gowns_box.position=(self.size.w/2, self.size.h * 0.59)
        self.gowns_box.fill_color=btn_color
        self.gowns_box.line_width=4
        self.gowns_box.stroke_color=btn_border_color
        self.gowns_box.shadow=btn_shadow
        self.add_child(self.gowns_box)                      
        self.wipes_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.wipes_box.position=(self.size.w/2, self.size.h * 0.49)
        self.wipes_box.fill_color=btn_color
        self.wipes_box.line_width=4
        self.wipes_box.stroke_color=btn_border_color
        self.wipes_box.shadow=btn_shadow        
        self.add_child(self.wipes_box)

        self.faq_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.faq_box.position=(self.size.w/2, self.size.h * 0.39)
        self.faq_box.fill_color=btn_color
        self.faq_box.line_width=4
        self.faq_box.stroke_color=btn_border_color
        self.faq_box.shadow=btn_shadow      
        self.add_child(self.faq_box)                

        self.dd_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.dd_box.position=(self.size.w/2, self.size.h * 0.29)
        self.dd_box.fill_color=btn_color
        self.dd_box.line_width=4
        self.dd_box.stroke_color=btn_border_color
        self.dd_box.shadow=btn_shadow       
        self.add_child(self.dd_box) 

        self.scene_title = LabelNode(app_title, font=(app_title_font, 50), position=(self.size.w/2, self.size.h * 0.90), color=text_color, parent=self) 

        self.mask_link = LabelNode('MASK',font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.80), color=text_color, parent=self)

        self.face_shield_link = LabelNode('FACE SHIELDS', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.70), color=text_color, parent=self)

        self.gown_link = LabelNode('GOWNS', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.60), color=text_color, parent=self)

        self.wipes_link = LabelNode('WIPES', (text_font, 30), position=(self.size.w/2, self.size.h * 0.50), color=text_color, parent=self)

        self.faq_link = LabelNode('FAQ', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.40), color=text_color, parent=self)

        self.faq_link = LabelNode("Dos/Don'ts", font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.30), color=text_color, parent=self)

        self.present_modal_scene(Intro())

    def did_change_size(self):
        pass

    def update(self):
        pass

    def touch_began(self, touch):
        if touch.location in self.mask_box.frame:
            self.present_modal_scene(Mask())

        if touch.location in self.sheild_box.frame:
            sc = Any()
            sc.title_param = 'FaceSheild.JPG'
            sc.image_param = 'Faceshield'
            sc.text_param  = 'Face sheilds protect the entire face, \nincluding the eyes, from any splashes \nor sprays, which along with the nose \nand mouth can be a gateway for the \ncoronavirus. Wearing a face shield \nmay make you less likely to touch your \nface with unwashed hands. You should \nware a face sheild while caring for \npatients. You never know what may \ncause something to splash towards \nyour face.'    

            self.present_modal_scene(sc)

        if touch.location in self.gowns_box.frame:
            self.present_modal_scene(Gowns())       

        if touch.location in self.wipes_box.frame:
            self.present_modal_scene(Wipes())       

        if touch.location in self.faq_box.frame:
            tv = ui.TableView()
            items = ['Q. What is the difference between \na K-N96 and a N95?', 'A. Both products are said to filter \n95 percent of aerosol particulates. \nKN95 respirators differ from N95 \nrespirators because they meet the \nChinese standard but are not \nregulated by U.S. agencies.', "Q. Do mask really work?", "A. Hell Yes"]
            tv.data_source = ui.ListDataSource(items=items)
            tv.present()        

        if touch.location in self.dd_box.frame:
            self.present_modal_scene(DD())

    def touch_moved(self, touch):
        pass

    def touch_ended(self, touch):
        pass

class Mask(Scene):
    def setup(self):

        self.bg_color = SpriteNode(color=bg_color, size=self.size, position=(self.size.w/2, self.size.h/2), parent=self)

        self.level_1_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.level_1_box.position=(self.size.w/2, self.size.h * 0.79)
        self.level_1_box.fill_color=btn_color
        self.level_1_box.line_width=4
        self.level_1_box.stroke_color=btn_border_color
        self.level_1_box.shadow=btn_shadow      
        self.add_child(self.level_1_box)    

        self.level_3_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.level_3_box.position=(self.size.w/2, self.size.h * 0.69)
        self.level_3_box.fill_color=btn_color
        self.level_3_box.line_width=4
        self.level_3_box.stroke_color=btn_border_color
        self.level_3_box.shadow=btn_shadow      
        self.add_child(self.level_3_box)    

        self.k_n95_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.k_n95_box.position=(self.size.w/2, self.size.h * 0.59)
        self.k_n95_box.fill_color=btn_color
        self.k_n95_box.line_width=4
        self.k_n95_box.stroke_color=btn_border_color
        self.k_n95_box.shadow=btn_shadow        
        self.add_child(self.k_n95_box)

        self.n95_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.n95_box.position=(self.size.w/2, self.size.h * 0.49)
        self.n95_box.fill_color=btn_color
        self.n95_box.line_width=4
        self.n95_box.stroke_color=btn_border_color
        self.n95_box.shadow=btn_shadow      
        self.add_child(self.n95_box)

        self.papr_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.papr_box.position=(self.size.w/2, self.size.h * 0.39)
        self.papr_box.fill_color=btn_color
        self.papr_box.line_width=4
        self.papr_box.stroke_color=btn_border_color
        self.papr_box.shadow=btn_shadow     
        self.add_child(self.papr_box)

        self.back = SpriteNode('iob:ios7_redo_32', position=(self.size.w * 0.87, self.size.h * 0.93), parent=self)

        self.scene_title = LabelNode('Mask', font=(app_title_font, 50), position=(self.size.w/2, self.size.h * 0.90), color=text_color, parent=self)                                    
        self.level_1_link = LabelNode('Level 1',font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.80), color=text_color, parent=self)

        self.level_3_link = LabelNode('Level 3', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.70), color=text_color, parent=self)

        self.k_n95_link = LabelNode('K-N95', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.60), color=text_color, parent=self)     

        self.n95_link = LabelNode('N95', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.50), color=text_color, parent=self)     

        self.papr_link = LabelNode('PAPR', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.40), color=text_color, parent=self)

        self.lvl3_mask = SpriteNode('FrontMask 2.PNG', position=(self.size.w * 0.75, self.size.h * 0.30), scale=0.25, parent=self)

        self.kn95_mask = SpriteNode('Kn95Mask.PNG', position=(self.size.w * 0.25, self.size.h * 0.15), scale=0.23, parent=self)

        self.n95_mask = SpriteNode('N95Mask.PNG', position=(self.size.w * 0.25, self.size.h * 0.29), scale=0.23, parent=self)   

        self.papr_mask = SpriteNode('PaprMask.PNG', position=(self.size.w * 0.60, self.size.h * 0.17), scale=0.50, parent=self)

    def touch_began(self, touch):
        if touch.location in self.level_1_box.frame:        
            sc = Any()
            sc.title_param = 'LEVEL 1'
            sc.image_param = 'FrontMask 2.PNG'
            sc.text_param  = "A level 1 mask provides adequate \nprotection in areas such as lobbies \nand the cafeteria. Its primary \nfunction is to stop any saliva\nor mucus from being transfered from \nperson to person \nIt's not recommended to wear \na level 1 mask while caring \nfor patients."
            self.present_modal_scene(sc)

        if touch.location in self.level_3_box.frame:
            sc = Any()
            sc.title_param = 'LEVEL 3'
            sc.image_param = 'Level3Mask.PNG'
            sc.text_param  = "A level 3 mask provides a higher \nlevel of protection than a level 1. \nAlthougth it looks very similar \na level 1 it can be distinguished \nfrom a level 1 by having at least 3 \nlayers of material. It also might \nhave a anti-fog stip to help with \nfogging. It's ok to ware a level 3 \nwhile around patients."
            self.present_modal_scene(sc)

        if touch.location in self.k_n95_box.frame:
            sc = Any()
            sc.title_param = 'K-N95'
            sc.image_param = 'Kn95Mask.PNG'
            sc.text_param  = "K-N95 masks are usually thicker \nand tighter fitting than a level 1 or 3 \nand provide a higher level of \nprotection. It's recommended for \nuse in patient areas such as the \nEmergency Dept and patient floors. \nA K-N95 is NOT fit tested and is \nNOT the same as a N95."
            self.present_modal_scene(sc)

        if touch.location in self.n95_box.frame:
            sc = Any()
            sc.title_param = 'N95'
            sc.image_param = 'N95Mask.PNG'
            sc.text_param  = "This is a N95 mask. \nIt should be worn while \ncaring for patients undergoing \nmedical procedures that \nhave been deemed as \naerosol generating procedures. \nYou should wear the N95 \nyou passed a fit test for."
            self.present_modal_scene(sc)

        if touch.location in self.papr_box.frame:
            sc = Any()
            sc.title_param = 'Papr'
            sc.image_param = 'PaprMask.PNG'
            sc.text_param  = "This is a Papr mask. \nIt is recommended for \nuse by individuals who \nhave not been or did not \npass a fit test. You should \nbe trained to ensure you \nproperly wear and clean \nthe Papr."
            self.present_modal_scene(sc)

        if touch.location in self.back.frame:
            self.dismiss_modal_scene()

class Any(Scene):
    def setup(self):

        self.bg_color = SpriteNode(color=bg_color, size=self.size, position=(self.size.w/2, self.size.h/2), parent=self)    

        self.root_node = Node(parent=self)  

        for i in (self.size.w/2, self.size.h * 0.8), (self.size.w/2, self.size.h * 0.4), (self.size.w/2, self.size.h * 0.1):
            self.text_line = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.8, 0, 20))
            self.text_line.position=i
            self.text_line.fill_color=btn_color
            self.text_line.line_width=4
            self.text_line.stroke_color=text_color
            self.add_child(self.text_line)

            self.title = LabelNode(self.title_param, (app_title_font, 30), position=(self.size.w/2, self.size.h * 0.85), color=text_color, parent=self)

            self.image = SpriteNode(self.image_param, position=(self.size.w/2, self.size.h * 0.60), scale=0.50, parent=self)

        self.txt = text

        self.discription = LabelNode(f'{self.text_param}', (text_font, 20), position=(self.size.w/2, self.size.h * 0.25), color=text_color, parent=self)    

        self.back = SpriteNode('iob:ios7_redo_32', position=(self.size.w * 0.87, self.size.h * 0.95), parent=self)      

    def touch_began(self, touch):
        if touch.location in self.back.frame:
            self.dismiss_modal_scene()

class Gowns(Scene):
    def setup(self):

        self.bg_color = SpriteNode(color=bg_color, size=self.size, position=(self.size.w/2, self.size.h/2), parent=self)    

        self.root_node = Node(parent=self)

        self.cloth_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.cloth_box.position=(self.size.w/2, self.size.h * 0.79)
        self.cloth_box.fill_color=btn_color
        self.cloth_box.line_width=4
        self.cloth_box.stroke_color=btn_border_color
        self.cloth_box.shadow=btn_shadow        
        self.root_node.add_child(self.cloth_box)    

        self.plastic_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.plastic_box.position=(self.size.w/2, self.size.h * 0.69)
        self.plastic_box.fill_color=btn_color
        self.plastic_box.line_width=4
        self.plastic_box.stroke_color=btn_border_color
        self.plastic_box.shadow=btn_shadow      
        self.root_node.add_child(self.plastic_box)  

        self.scene_title = LabelNode('Gowns', font=(app_title_font, 50), position=(self.size.w/2, self.size.h * 0.90), color=text_color, parent=self)

        self.cloth_link = LabelNode('Cloth', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.80), color=text_color, parent=self.root_node)

        self.plastic_link = LabelNode('Plastic',font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.70), color=text_color, parent=self.root_node)

        self.cloth_label = LabelNode('Cloth', font=(text_font, 30), position=(self.size.w  * 0.25, self.size.h * 0.50), color=text_color, parent=self.root_node)                                        
        self.plastic_label = LabelNode('Plastic',font=(text_font, 30), position=(self.size.w * 0.75, self.size.h * 0.60), color=text_color, parent=self.root_node)

        self.plastic = SpriteNode('PlasticGown.PNG', position=(self.size.w * 0.75, self.size.h * 0.40), scale=0.75, parent=self.root_node)

        self.cloth = SpriteNode('ClothGown.PNG', position=(self.size.w * 0.26, self.size.h * 0.26), scale=0.70, parent=self)        

        self.back = SpriteNode('iob:ios7_redo_32', position=(self.size.w * 0.87, self.size.h * 0.95), parent=self)      

    def touch_began(self, touch):

        if touch.location in self.cloth_box.frame:
            sc = Any()
            sc.title_param = 'CLOTH'
            sc.image_param = 'ClothGown.PNG'
            sc.text_param  = 'This is a cloth gown. \nIt must be worn while \nproviding care to patients \nwho are in isolation. \n\nIts NOT recommended to \nwear a cloth gown while \ncaring for patients \nwith C-diff or TB.'
            self.present_modal_scene(sc)

        if touch.location in self.plastic_box.frame:
            sc = Any()
            sc.title_param = 'PLASTIC'
            sc.image_param = 'PlasticGown.PNG'
            sc.text_param  = 'This is a plastic gown. \nIt must be worn while \nproviding care to C-Diff \npatients. \n\nIts is recommended to \nwear a plastic gown while \nproviding care to patients \nwith TB.'
            self.present_modal_scene(sc)

        if touch.location in self.back.frame:
            self.dismiss_modal_scene()  

class Wipes(Scene):
    def setup(self):
        self.bg_color = SpriteNode(color=bg_color, size=self.size, position=(self.size.w/2, self.size.h/2), parent=self)            

        self.oxy_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.oxy_box.position=(self.size.w/2, self.size.h * 0.79)
        self.oxy_box.fill_color=btn_color
        self.oxy_box.line_width=4
        self.oxy_box.stroke_color=btn_border_color
        self.oxy_box.shadow=btn_shadow      
        self.add_child(self.oxy_box)    

        self.sani_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.sani_box.position=(self.size.w/2, self.size.h * 0.69)
        self.sani_box.fill_color=btn_color
        self.sani_box.line_width=4
        self.sani_box.stroke_color=btn_border_color
        self.sani_box.shadow=btn_shadow     
        self.add_child(self.sani_box)   

        self.bleach_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.bleach_box.position=(self.size.w/2, self.size.h * 0.59)
        self.bleach_box.fill_color=btn_color
        self.bleach_box.line_width=4
        self.bleach_box.stroke_color=btn_border_color
        self.bleach_box.shadow=btn_shadow       
        self.add_child(self.bleach_box)

        self.ammonia_box = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.65, self.size.h * 0.07, 20))
        self.ammonia_box.position=(self.size.w/2, self.size.h * 0.49)
        self.ammonia_box.fill_color=btn_color
        self.ammonia_box.line_width=4
        self.ammonia_box.stroke_color=btn_border_color
        self.ammonia_box.shadow=btn_shadow      
        self.add_child(self.ammonia_box)

        self.scene_title = LabelNode('Wipes', font=(app_title_font, 50), position=(self.size.w/2, self.size.h * 0.90), color=text_color, parent=self)   

        self.oxy_link = LabelNode('Oxyvir',font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.80), color=text_color, parent=self)

        self.alcohol_link = LabelNode('Sani (alcohol)', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.70), color=text_color, parent=self)

        self.bleach_link = LabelNode('Bleach', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.60), color=text_color, parent=self)

        self.ammonia_link = LabelNode('Ammonia', font=(text_font, 30), position=(self.size.w/2, self.size.h * 0.50), color=text_color, parent=self)     

        self.oxy = SpriteNode('OxyvirWipes.PNG', position=(self.size.w * 0.29, self.size.h * 0.35), scale=0.30, parent=self)

        self.alcohol = SpriteNode('SaniWipes.PNG', position=(self.size.w * 0.75, self.size.h * 0.35), scale=0.30, parent=self)

        self.bleach = SpriteNode('BleachWipes.PNG', position=(self.size.w * 0.30, self.size.h * 0.15), scale=0.30, parent=self) 

        self.ammonia = SpriteNode('AmmoniaWipes.PNG', position=(self.size.w * 0.75, self.size.h * 0.15), scale=0.30, parent=self)

        self.back = SpriteNode('iob:ios7_redo_32', position=(self.size.w * 0.87, self.size.h * 0.95), parent=self)      

    def touch_began(self, touch):

        if touch.location in self.back.frame:
            self.dismiss_modal_scene()  

        if touch.location in self.oxy_box.frame:
            sc = Any()
            sc.title_param = 'OXIVIR'
            sc.image_param = 'OxyvirWipes.PNG'
            sc.text_param  = 'Oxivir is recommended for general \ndisinfecting. The active ingredient \nhydrogen peroxide. It does NOT \nkill the bacteria that causes C-Diff \nand should never be used to \ndisinfect anything that may be \ncontaminated with C-Diff.'
            self.present_modal_scene(sc)

        if touch.location in self.sani_box.frame:
            sc = Any()
            sc.title_param = 'SANI'
            sc.image_param = 'BleachWipes.PNG'
            sc.text_param  = 'Bleach is a Sporicidal disinfectant. \nThe active ingredient is Sodium \nhypochlorite. Bleach kills the \nbacteria that causes C-Diff \nand should always be used to \ndisinfect anything that may be \ncontaminated with C-Diff.'
            self.present_modal_scene(sc)

        if touch.location in self.bleach_box.frame:
            sc = Any()
            sc.title_param = 'BLEACH'
            sc.image_param = 'SaniWipes.PNG'
            sc.text_param  = 'Sani is recommended for general \ndisinfecting. The active ingredient \nis Alcohol. It does NOT kill the \nbacteria that causes C-Diff and \nshould never be used to \ndisinfect anything that may be \ncontaminated nwith C-Diff.'
            self.present_modal_scene(sc)

        if touch.location in self.ammonia_box.frame:
            sc = Any()
            sc.title_param = 'AMMONIA'
            sc.image_param = 'AmmoniaWipes.PNG'
            sc.text_param  = 'Ammonia is recommended for \ncleaning sensitive electiral devices. \nThe active ingredient Ammonia. \nIt does NOT kill the bacteria that \ncauses C-Diff and should never \nbe used to disinfect anything that \nmay be contaminated with C-Diff.'
            self.present_modal_scene(sc)

if __name__ == '__main__':
    run(MyScene(), show_fps=False)

ccc

Typos discovered by codespell --quiet-level=2

./PPEasy.py:29: discription ==> description
./PPEasy.py:121: sheild ==> shield
./PPEasy.py:217: transfered ==> transferred
./PPEasy.py:272: discription ==> description
resserone13

@ccc thanks. I notice you caught those errors. Did you request to merge the code that I just posted. I want to merge it but I’m not sure if you’re trying to merge my new code?

ccc

Yes. The pull request is your code unmodified.

resserone13

@ccc ok. Thanks. I wasn’t sure how to merge it. I’m not too familiar with GitHub.

ccc

https://github.com/resserone13/PPEasy/pull/3 Click Merge

resserone13

@ccc I found the merge button. I was referring to just uploading all the new code and setting it to merge with the old file

ccc

PPEasy running on an M1 MacBook Pro with git in iTerm below, Pythonista iOS app in the macOS Applications folder and the GitHub repo opened in Firefox.
Screenshot 2021-01-01 at 12 17 12

resserone13

@cvp I’m trying to add som ui aspects to your Any() scene. Right now I’m try to add a lane that scales to fit the text area. This is what I have.


class New_Any(Scene):
    def setup(self):
        self.bg_color = SpriteNode(color=bg_color, size=self.size, position=(self.size.w/2, self.size.h/2), parent=self)    

        for i in (self.size.w/2, self.size.h * 0.8), (self.size.w/2, self.size.h * 0.4), (self.size.w/2, self.size.h * 0.1):
            self.text_line = ShapeNode(ui.Path.rounded_rect(0, 0, self.size.w * 0.8, 0, 50))
            self.text_line.position=i
            self.text_line.fill_color=btn_color
            self.text_line.line_width=3
            self.text_line.stroke_color=text_color
            self.add_child(self.text_line)

        self.title = LabelNode(self.title_param, (app_title_font, 30), position=(self.size.w/2, self.size.h * 0.87), color=text_color, parent=self)

        self.image = SpriteNode(self.image_param, scale=self.scale_param, position=(self.size.w/2, self.size.h * 0.60), parent=self)

        self.dwell_t = LabelNode(self.dwell_param, (app_title_font, 20), position=(self.size.w/2, self.size.h * 0.43), color=text_color, parent=self)

        description = ui.Label()
        description.editable=False
        description.scales_font=True
        description.line_break_mode=LB_CHAR_WRAP
        description.text = self.text_param
        description.font = text_font, 20
        description.frame= (50, 50, 50, 50)
        description.present(hide_title_bar=True)

        self.back = SpriteNode('iob:ios7_undo_32', position=(self.size.w * 0.87, self.size.h * 0.93), parent=self)      

    def touch_began(self, touch):
        if touch.location in self.back.frame:
            self.dismiss_modal_scene()



cvp

@resserone13 said:

your Any() scene.

Please, don't say your , it was only to show you how to use only once your code.
In five years of Pythonista, I wrote a lot of scripts but I never have used scene, thus you can understand that I can't help you in this matter. 😀

resserone13

@cvp I was really asking for help using ui module. I was Trying to work with the tableview you showed me. Now I’m trying to work with ui.label. For the tableview I was having trouble coloring the background for each cell. You had showed me how to create the data source but I couldn’t change the cell color. For labelview I was having some of the same issues? I provided the label I’m trying to make. Thank for any help. I know you are busy. Thanks.

Update.

Actually See you kind of gave me example above. I will try to review that. Thanks

cvp

@resserone13 TableView cell color

import ui
tv = ui.TableView()
items = ['faq 1', 'faq 2', 'faq 3', 'faq 4', 'faq 5']
def my_tableview_cell_for_row(tableview,section,row):
    cell = ui.TableViewCell()
    cell.text_label.text = tableview.data_source.items[row]
    cell.text_label.background_color = (1-0.1*row,0,0)
    return cell
tv.data_source = ui.ListDataSource(items=items)
tv.data_source.tableview_cell_for_row = my_tableview_cell_for_row
tv.present()

cvp

@resserone13 said:

For labelview I was having some of the same issues

What is your problem?

resserone13

@cvp the label text is only displaying the first line of a huge paragraph.


                    tv = ui.Label()
            tv.alignment= ui.ALIGN_LEFT
            tv.line_break_mode = ui.LB_CHAR_WRAP
            tv.text = 'Symptoms may appear 2-14 days after \nexposure to the virus. People with these \nsymptoms 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. \nIf someone is showing any of \nthese signs, seek emergency medical \ncare 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'
            tv.present()


cvp

@resserone13 try

from objc_util import *
ObjCInstance(tv).numberOfLines = 0
mikael

@cvp, regular Label property number_of_lines, set to 0, no need for ObjC.

cvp

@mikael sincerely, I knew that. Why did I forget it? Is it not the proof that I have to stop to develop code?