• resserone13

    @cvp @ccc @mikael Here is the UI version of the personal protective equipment app. It looks kind of plain. Any suggestions to spruce up how it looks?

    https://github.com/resserone13/PPEasy-ui-only

    posted in Pythonista read more
  • resserone13

    @Python567 Make a button action that displays the view you would like for each button.

    Kinda like

    
    def lvl_1_pg(sender):
        v = Main_View()
        v.add_title('Level 1')
        v.add_img(level_1_img, 0.15, 0.12, 300, 300)
        v.add_textview(info[1], width * 0.12, height * 0.50, width * 0.75, height * 0.60)
        v.present('full_screen', hide_title_bar=True)
      
    def lvl_3_pg(sender):
        v = Main_View()
        v.add_title('Level 3')
        v.add_img(level_3_img, 0.05, 0.12, 375, 375)
        v.add_textview(info[2], width * 0.12, height * 0.50, width * 0.75, height * 0.60)
        v.present('full_screen', hide_title_bar=True)
        
    def kn95_pg(sender):
        v = Main_View()
        v.add_title('Kn95')
        v.add_img(kn95_img, 0.15, 0.12, 300, 300)
        v.add_textview(info[3], width * 0.12, height * 0.50, width * 0.75, height * 0.60)
        v.present('full_screen', hide_title_bar=True)
    
    
    

    posted in Pythonista read more
  • resserone13

    @Python567 so you would like the next menu to be determined by the button you press on the previous menu? Is that correct?

    posted in Pythonista read more
  • resserone13

    @Python567 The way I could think of doing it would be to keep track of how many times the button is pressed with a variable. Assign a different action to each time pressed. You can use an if statement to check how many times the button has been pressed and what action should Correspond to that amount of presses. I haven’t tested this but it is what I would try. I can guarantee there’s a better more efficient way but I’m just trying to help.

    
    Btn_presses = 0
    def btn_tapped(sender):
        Btn_presses += 1   
        if presses == 1:
            Print(‘hello’)
        elif presses == 2:
            Print(‘ bye’)
        elif  Btn_presses == 3:
            print(3)
            Btn_presses=0
    
    

    posted in Pythonista read more
  • resserone13

    @Python567 so you want the buttons action to change each time it’s pressed?

    posted in Pythonista read more
  • resserone13

    @Python567 yes. It creates a button and assigns the button an action.

    posted in Pythonista read more
  • resserone13

    @Python567

    Btn.action = a

    a Is each item in your list of actions.

    Each time you go through the 4 loop it’ll create a button from the name and it will add an action from the list of actions. If you put five names and five actions you will have five buttons with their own actions. Make a list of button names and a list of actions for the buttons then feed it to the function. For the function you can create a class and use it as a class method.

    posted in Pythonista read more
  • resserone13

    I’m using this. It takes a list of but names that it makes buttons out of and is it assigns the action to each button. Your list of button names has to have a list of actions in the same order as your butt names and the same length.

    
        def add_btn(self, btn_names, actions_list,):
            for i, (n, a) in enumerate(zip(btn_names, actions_list)):
                btn= ui.Button()
                btn.background_color=btn_clr
                btn.title=n
                btn.font=(btn_fnt, btn_txt_sz)
                btn.tint_color=txt_clr
                btn.border_width=2
                btn.border_color=txt_clr
                btn.frame=(width * 0.15, height * (0.10 + i * 0.1), width * 0.7, height * 0.07)
                btn.corner_radius= btn_corner_radius
                btn.action=a
                self.add_subview(btn)
                
    
    

    posted in Pythonista read more
  • resserone13

    Thanks @cvp @ccc and @mikael for the help. I was able to get past the hang up and move forward on the app development. I ended up using @ccc suggestion because i was using code very similar to what I already had. I’m finishing up a few more things then I will post on GitHub.

    
        def add_btn(self, btn_names, actions_list):
            for i, (n, a) in enumerate(zip(btn_names, actions_list)):
                btn= ui.Button()
                btn.background_color=btn_clr
                btn.title=n
                btn.font=(btn_fnt, btn_txt_sz)
                btn.tint_color=txt_clr
                btn.border_width=2
                btn.border_color=txt_clr
                btn.frame=(width * 0.15, height * (0.12 + i * 0.1), width * 0.7, height * 0.05)
                btn.corner_radius= btn_corner_radius
                btn.action=a
                self.add_subview(btn)
    
    

    posted in Pythonista read more
  • resserone13

    I have a for loop that loops over btn names and creates a button for each name. How do I make it loop over a list of btns and a list of actions so that the each button gets a name and an action?
    I’m using enumerate to help space the btns out. I tired switching to zip but then I loose the i variable for the enumerate function?

    
        def add_btn(self, btn_names, actions_list):
            for i, name, a in enumerate((btn_names)):
                btn= ui.Button()
                btn.background_color=btn_clr
                btn.title=name
                btn.font=(btn_fnt, btn_txt_sz)
                btn.tint_color=txt_clr
                btn.border_width=2
                btn.border_color=txt_clr
                btn.frame=(width * 0.15, height * (0.12 + i * 0.1), width * 0.7, height * 0.05)
                btn.corner_radius= btn_corner_radius
                btn.action='?????'
                self.add_subview(btn)
                
    
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!