• Enez Houad

    @cvp Eureka ! I finally solved my problem that had nothing to do with my class AttributedTextView and with objC.
    Just a problem with settings assigned to an array ...

    posted in Pythonista read more
  • Enez Houad

    @cvp Thanks ! I'm going to search by myself (to progress ;-) and if I don't find, I'll come back for help…

    posted in Pythonista read more
  • Enez Houad

    I created an AttributedTextView class from my demo script. Unfortunately Pythonista crashes when I run the script several times in a row. In the faultlog, I see NSRangeException: *** - [__ NSArrayM objectAtIndex:] index 5 beyound bounds [0 .. 4] but I don't understand what it meens.
    A track, please, to solve my problem…

    posted in Pythonista read more
  • Enez Houad

    Here is my demo script (with the help of cvp) of attributed TextView. You can change text color, font and paragraph attributes.

    import ui
    from objc_util import *
    
    def fake_text():
        import random, faker    
        return faker.Faker().text(random.randint(500, 500))
    
    tv = ui.TextView(frame = (0, 0, 500, 500))
    tv.editable = False
    tvobj = ObjCInstance(tv)
    
    text = fake_text()
    
    NSMutableParagraphStyle = ObjCClass('NSMutableParagraphStyle').alloc()
    NSMutableParagraphStyle.setLineSpacing_(20.0)
    NSMutableParagraphStyle.setParagraphSpacing_(40.0)
    NSMutableParagraphStyle.setFirstLineHeadIndent_(30.0)
    NSMutableParagraphStyle.setHeadIndent_(10)
    NSMutableParagraphStyle.setAlignment_(3) # justified
    NSParagraphStyle = ns('NSParagraphStyle')
    
    NSMutableAttributedString = ObjCClass('NSMutableAttributedString').alloc()
    NSMutableAttributedString.initWithString_(text)
    
    UIColor = ObjCClass('UIColor')
    NSForegroundColorAttributeName = ns('NSColor')
    color = UIColor.colorWithRed_green_blue_alpha_(1, 0, 0, 1)
    
    UIFont = ObjCClass('UIFont')
    NSFontAttributeName = ns('NSFont')
    font = UIFont.fontWithName_size_('Optima', 18)
    
    attributes = {  NSParagraphStyle:NSMutableParagraphStyle,
                    NSForegroundColorAttributeName:color,
                    NSFontAttributeName:font}
    NSMutableAttributedString.setAttributes_range_(attributes, NSRange(0, len(text)))
    
    tvobj.attributedText = NSMutableAttributedString
    
    tv.present('sheet')
    

    posted in Pythonista read more
  • Enez Houad

    @cvp Bravo ! I've seen sooner this topic but didn't understood ;-)
    Thank you very much.
    I'm a retired school teacher and I've developed during the last 35 last years free apps for school on Mac (Hypercard and Livecode). I'm now retired but I would like to develop this apps for iPad and Pythonista is a wonderful tool for this work. So I need to prepare my objects before making my new versions of apps. Attributed TextView is one of the object I need.
    And now : Au travail !

    posted in Pythonista read more
  • Enez Houad

    @cvp Thanks ! Effectively, doesn't do what I want ;-) But new tracks to explore :-))

    posted in Pythonista read more
  • Enez Houad

    A new problem for me with may be solved with objc and UIKit ;-)
    I want to change the line spacing of a ui.TextView. I’ve followed the advice given by cvp (searching on the web) and found objc examples. Here is one that looks ok :

    let tv = UITextView()
        tv.tintColor = UIColor.darkGray
        tv.font = UIFont.systemFont(ofSize: 17)
        tv.backgroundColor = UIColor.white
        let spacing = NSMutableParagraphStyle()
        spacing.lineSpacing = 4
        let attr = [NSParagraphStyleAttributeName : spacing]
        tv.typingAttributes = attr
    

    I’ve tried to « translate » it in Pythonista, but my script never works. After 3 days of research, I'm desperate.
    Please , help me ;-)

    posted in Pythonista read more
  • Enez Houad

    I've reinstalled the old appstore version and … Youpi ! all is is in his place. I can sleep ! Now, I'm going to wait for the old new version ;-)

    posted in Pythonista read more
  • Enez Houad

    No ! unfortunately.

    posted in Pythonista read more
  • Enez Houad

    France 10:00 PM - My Beta has expired. I could'nt think it could happend… And now, it's impossible to launch Pythonista…
    Fortunately the majority of my work is in iCloud but not all :-(((
    My personal modules are in the site-packages 3.
    Does someone know if there's a way to recover my work ?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!