Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Personal Protective Equipment App
-
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.
-
@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. -
@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.
-
@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()
-
@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
-
@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)
-
@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.
-
@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)
-
@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
-
@resserone13 Normally, Scene is made for animation or games and I am not used to using it. Personally, I would have used ui.View.
-
@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.
-
@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.
-
@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.
-
@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.
-
@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
-
@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.?
-
@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()
-
@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.
-
@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')
-
@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.