• peiriannydd

    Yes, thank you, this solved my problems, although using a label since <system-bold> doesn’t work with ui.draw_string seems like a bug workaround.

    posted in Pythonista read more
  • peiriannydd

    Two issues:

    1. When I try to create a custom view with the pyui I am unable to created rounded corners, but if instead I create the custom view without the pyui I get rounded corners.
    2. When I try to use <system-bold> font in a custom view the text is not bold.

    How do I solve this? Thanks for any help!

    Here is an example that illustrates both:

    import ui
    
    class customButton(ui.View):
      def __init__(self,frame=(0,0,300,100)):
        self.corner_radius = 8
        self.frame = frame
        self.text = 'why does only one of these have rounded corners and neither have bold text?'
    
      def draw(self):
        path = ui.Path.rounded_rect(0,0, self.width,self.height,self.corner_radius)
        ui.set_color('green')
        path.fill()
        ui.draw_string(self.text,(0,0,self.width,self.height),('<system-bold>',20),'black',ui.ALIGN_CENTER)
    
    
    #the pyui file consists of a single custom view, with
    # x=20
    # y=200
    # width=300
    # height=100
    # custom view class = customButton
    v = ui.load_view()
    cbn = customButton()
    v.add_subview(cbn)
    v.present('fullscreen')

    posted in Pythonista read more
  • peiriannydd

    Thank you cvp, I appreciate your help

    posted in Pythonista read more
  • peiriannydd

    Now instead of reading (0,0) when no rows are selected I read (0,<last_selected_row>) when no rows are selected

    posted in Pythonista read more
  • peiriannydd

    Sorry, I lost the indent tabs on the def: above

    posted in Pythonista read more
  • peiriannydd

    If you press the ‘check’ button when no rows are selected, it shows (0,0), the same as when the first row is selected:

    import ui
    
    def check_selected_row(sender):
        #print(tbl.selected_row)
        lbl.text = str(tbl.selected_row)
        tbl.reload_data()
    
    v = ui.View(bg_color='white')
    tbl = ui.TableView(frame=(50,0,100,180))
    
    data = ('zero','one','two')
    tbl.data_source=ui.ListDataSource(data)
    
    btn = ui.Button(frame=(250,100,0,0),bg_color='yellow',title='check',action=check_selected_row)
    
    lbl = ui.Label(frame=(50,220,100,100))
    
    v.add_subview(btn)
    v.add_subview(tbl)
    v.add_subview(lbl)
    v.present('fullscreen')
    

    posted in Pythonista read more
  • peiriannydd

    If I read tableview.selected_row, it returns (0,0) if the first row is selected, but it also returns (0,0) if no rows are selected. How can I tell whether the first row of a tableview is selected or not?

    posted in Pythonista read more
  • peiriannydd

    Thank you JonB! I knew I must be missing something, and I never would have figured that out.

    posted in Pythonista read more
  • peiriannydd

    I’m sorry if this has an obvious answer, but I am unable to get this to work. I want to use a custom close button but it doesn’t work for me. What am I missing? Thank you!

    ` import ui

    v = ui.View()

    b1 = ui.Button(title = "why doesn't this close button work?")
    b1.frame = (50,100,270,50)
    b1.background_color = '#d0d0d0'
    b1.action = v.close()

    v.add_subview(b1)
    v.present('fullscreen', hide_title_bar=True)```

    posted in Pythonista read more
  • peiriannydd

    @mikael fantastic! Thank you so much. It works great. I really appreciate your time and @cvp to help out an inexperienced python user like me.

    posted in Pythonista read more
  • peiriannydd

    @cvp yes, but I was hoping to change the font within the label, and <f 'Times New Roman' 60> doesn't work. For example, this doesn't work:

        r = RichLabel(
          font=('Chalkboard SE', 60),
          background_color='white',
          alignment=ui.ALIGN_CENTER,
          number_of_lines=0,
        )
    
        r.rich_text("\n".join([
          "First font",
          "<f 'Times New Roman' 60>Second font</f>, 
        ]))

    posted in Pythonista read more
  • peiriannydd

    @mikael I have enjoyed using your richlabels (thank you!!). One thing I haven’t figured out - When I try to change the font with

    <f times new roman 15>

    I get an error that it can't find a font named times. It seems like it is looking for the first word only in the font name. I don’t know python syntax well enough - is there a way I can write my code that will combine the whole three-word string when passed to the richlabels parser to have a multiword font, or is this a limitation of the richlabels module?

    Thanks again!

    posted in Pythonista read more
  • peiriannydd

    @ccc I'm afraid I don't follow. I'm using Py3, and neither u'anā\B' nor r'anā\B' catch the expression I need to replace. Is there anything I can do?

    Thank you very much for your time.

    posted in Pythonista read more
  • peiriannydd

    I get a complaint of a syntax error when I try
    replaced = re.sub(ru'anā\B', u'nā', s)
    It is complaining about the ru together. This syntax does work on my Mac. Is there a way this works in Pythonista?

    posted in Pythonista read more
  • peiriannydd

    @mikael @cvp I’m indifferent to the format, as you said, HTML is more usual, but any other format with at least as much flexibility would be fine. I think this a fantastic feature in any case.

    posted in Pythonista read more
  • peiriannydd

    Just wondering if this is easy, or would it require gestures?

    posted in Pythonista read more
  • peiriannydd

    I see what is the problem with (1), the icon is grabbed correctly when I used my iPad but not my iPhone. I have the same directory path duplication problem (2) on my iPad as my iPhone, though.

    posted in Pythonista read more
  • peiriannydd

    Is it supposed to? If so, what am I missing?

    1.While editing my .py file, I tap on the wrench, then on ↗️Shortcuts... then on Home Screen Icon, then on Continue, then on the share button in the toolbar, then Add to Home Screen, then Add, and I get an icon that looks like this:
    bad icon
    Instead of like this:
    good icon

    2.Then when I tap the icon, I get
    Not Found The file “flashcards/flashcards/flashcards_new.py” could not be found.
    I was able to work around this second problem by creating a flashcards subdirectory so that the path was correct

    Are these known issues?

    posted in Pythonista read more
  • peiriannydd

    @mikael @cvp Thank you both, I will certainly be able to figure this out based on your suggestions. I appreciate your help.

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!