Personal Protective Equipment App
@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.
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.
@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()
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. 😀
@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.
Actually See you kind of gave me example above. I will try to review that. Thanks
@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()
For labelview I was having some of the same issues
What is your problem?
@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()
from objc_util import * ObjCInstance(tv).numberOfLines = 0
@cvp, regular Label property
number_of_lines, set to 0, no need for ObjC.
@mikael sincerely, I knew that. Why did I forget it? Is it not the proof that I have to stop to develop code?