• cvp

    @ihf if you want something new, don't hesitate.

    Next week, I will continue converting outline.py from TableView to scrollView

    posted in Pythonista read more
  • cvp

    @jaalburquerque as adviced by @JonB , you can use ObjectiveC text attributes

    import random
    from objc_util import *
    .
    .
    .
        lt.text = title 
        
        # set color attributes
        attrtext = ObjCClass('NSMutableAttributedString').alloc().initWithString_(title)
        for i in range(len(title)):
            color = ObjCClass('UIColor').colorWithRed_green_blue_alpha_(random.random(), random.random(), random.random(), 1.0)
            attrtext.addAttribute_value_range_('NSColor',color,NSRange(i, 1))
        ObjCInstance(lt).setAttributedText_(attrtext)
    
    

    posted in Pythonista read more
  • cvp

    @jaalburquerque a Quick and dirty script as starting point for you.

    import ui
    
    def myalert(title, message, button1, button2=None, button3=None, hide_cancel_button=False):
    
        v = ui.View()
        v.background_color = 'white'
        w = 270
        y = 10
        lt = ui.Label()
        lt.font = ('Menlo',16)
        lt.text_color = 'red'
        lt.text = title
        lt.alignment = ui.ALIGN_CENTER
        lt.number_of_lines = 0
        y += 10
        lt.frame = (10,y,w-2*10,lt.font[1])
        lt.size_to_fit()
        ht = lt.height
        lt.frame = (10,y,w-2*10,ht)
        v.add_subview(lt)   
        y += ht
        
        lm = ui.Label()
        lm.font = ('Menlo',16)
        lm.text_color = 'green'
        lm.text = message
        lm.alignment = ui.ALIGN_CENTER
        lm.number_of_lines = 0
        y += 10
        lm.frame = (10,y,w-2*10,lt.font[1])
        lm.size_to_fit()
        hm = lm.height
        lm.frame = (10,y,w-2*10,hm)
        v.add_subview(lm)   
        y += hm
        
        li = ui.Label()
        y += 10
        li.frame = (0,y,w,1)
        li.border_width = 1
        li.border_color = 'lightgray'
        v.add_subview(li)
        
        b = ui.SegmentedControl()
        segments = []
        if not hide_cancel_button:
            segments.append('cancel')  
        if button1:
            segments.append(button1)  
        if button2:
            segments.append(button2)  
        if button3:
            segments.append(button3)  
        x = 10 
        y += 10
        wb = (w - 10*(len(segments)+1))/len(segments)
        v.ret = None
        def b_action(sender):
            v.ret = sender.ret
            v.close()
        for i in range(len(segments)):
            b = ui.Button()
            b.font = ('<System-Bold>', 20)
            b.title = segments[i]
            b.ret = i
            b.action = b_action
            b.frame = (x,y,wb,24)
            v.add_subview(b)
            if i < (len(segments)-1):
                lv = ui.Label()
                lv.border_width = 1
                lv.border_color = 'lightgray'
                lv.frame = (x+wb+5,li.y,1,y+b.height+10-li.y)
                v.add_subview(lv)
            x += wb + 10
                
        y += b.height + 10
        v.frame = (0,0,w,y)
        
        v.present('sheet', hide_title_bar=True)
        v.wait_modal()
        return v.ret
    
    b = myalert('title, up to you to add color and even font parameters','message, supports long texts', button1='yes', button2='no')
    print(b)
    

    posted in Pythonista read more
  • cvp

    @jaalburquerque tint_color seems to work only for switch and check fields types. Sorry for you

    posted in Pythonista read more
  • cvp

    @ihf sorry for all these bugs...

    Anyway, That does not solve your request and I don't see a way to access an iCloud file without any user interaction. The only way I see is to copy the outline on your web server, perhaps encrypted, or password protected.

    posted in Pythonista read more
  • cvp

    @ihf new V00.04 of outline_viewer.html should correct this problem of erroneously associated items after a sort

    posted in Pythonista read more
  • cvp

    @ihf bugs will end when I'll stop to write code 😭

    Could you check dates if no sort?

    posted in Pythonista read more
  • cvp

    @ihf you're right, it is not the right solution. Sincerely, is selecting an outline file so heavy? I had also thought to cookies but not sure it could help. I'am open to any feasible solution.

    Perhaps I could store the last outline file as a local cookie but if you modify the file.....
    But you may have max 20 x 4K bytes of cookies per site

    posted in Pythonista read more
  • cvp

    @ihf sorry, I updated previous post during your connection, please read it.

    posted in Pythonista read more
  • cvp

    @ihf said:

    the web server does not need iCloud access as you are accessing the file from the client.

    I think it needs it if the Python program runs on the web server. If you run a code on the server, it is the server which access the file, not the client, at least, I think so.

    A solution is perhaps to modify outline.py to save at each file end (not update: end of script or new other) the outline file on the web server, via ftp, sftp, smb at your choice.
    The .html could access these local (on the web server) files, I don't know yet how but it should be possible, either via a selection, either via a fixed path

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!