• cvp

    @kami With exactly this little script? For me, it is ok

    posted in Pythonista read more
  • cvp

    @kami try this

    import ui
    from objc_util import *
    
    tv = ui.TextView()
    tv.frame = (0,0,500,500)
    tv.text = 'a'*12000
    
    b = ui.ButtonItem()
    b.title = 'bottom'
    def b_action(sender):
        tvo = ObjCInstance(tv)
        tvo.scrollRangeToVisible_(NSRange(len(tv.text),0))
        tvo.setScrollingEnabled_(False)
        tvo.setScrollingEnabled_(True)
        pass
    b.action = b_action
    tv.right_button_items = (b,)
    
    tv.present('sheet')
    

    posted in Pythonista read more
  • cvp

    I've played with Wipy one year ago but there was a lot of bugs thus the hw is now waiting in my cellar...

    posted in Pythonista read more
  • cvp

    @suzylw Same for me and a lot of us, I think 🤔

    posted in Pythonista read more
  • cvp

    @suzylw Ok, sorry, only to let you know

    posted in Pythonista read more
  • cvp

    @felix_42sol_eu and @kjv93 , no need to ask, beta is here

    posted in Pythonista read more
  • cvp

    @suzylw Did you see here

    posted in Pythonista read more
  • cvp

    @Vile thank only @jonb 😀

    posted in Pythonista read more
  • cvp

    Following @JonB advice, this works

    .
    .
    .
            self.last_t = self.t
            
        def update(self):
            #self.sprite.texture=sprite_sheet[1]
            if (self.t-self.last_t) > 0.05:
                #modify_the_sprite
                self.last_t = self.t
    .
    .
    .
    

    posted in Pythonista read more
  • cvp

    @octoshark see last post of this topic

    posted in Pythonista read more
  • cvp

    Same error and solution here and here

    Found via Google on module 'matplotlib' has no attribute 'cbook'

    posted in Pythonista read more
  • cvp

    And the big script also works....

    posted in Pythonista read more
  • cvp

    For me, this little script works also if in Pythonista iCloud

    import matplotlib.pyplot as plt
    x=[1,2]
    y=[1,2]
    plt.scatter(x,y)
    plt.show()
    

    posted in Pythonista read more
  • cvp

    Or IOS 13 bug

    posted in Pythonista read more
  • cvp

    @average install piexif.py from here
    and try this script

    from   datetime import datetime
    import dialogs
    from   objc_util import ObjCInstance
    import os
    import photos
    import piexif   # https://github.com/hMatoba/Piexif/tree/master/piexif
    
    def exif_as_str(exif_val):
        exif_str = str(exif_val)
        if len(exif_str) >= 3:
            if exif_str[:2] == "b'" and exif_str[-1] == "'":
                exif_str = exif_str[2:-1]
        return exif_str 
    
    def main():
        # select photo
        asset = photos.pick_asset()
        
        # get its path
        path = str(ObjCInstance(asset).pathForOriginalFile())
        #print(path)
    
        # get photo exifs
        exif_info = piexif.load(path)   
        exif_str = exif_as_str(exif_info['Exif'][piexif.ExifIFD.DateTimeOriginal])
        #print('photo taken date/time',exif_str)
    
        # get new taken date-time   
        new_date = dialogs.datetime_dialog(title=str(exif_str))
        dt_str = datetime.strftime(new_date,'%Y:%m:%d %H:%M:%S')
        
        # update exif of taken datetime
        exif_info['Exif'][piexif.ExifIFD.DateTimeOriginal] = dt_str 
        exif_str = exif_as_str(exif_info['Exif'][piexif.ExifIFD.DateTimeOriginal])
        #print('modified photo taken date/time',exif_str)
    
        # create new photo with modified taken date-time    
        exif_bytes = piexif.dump(exif_info)
        new_path = 'temp.jpg'
        piexif.insert(exif_bytes,path,new_file=new_path)
        photos.create_image_asset(new_path)
        os.remove(new_path)
                
    #--- protect for import
    if __name__ == '__main__':
        main()
    

    If any error, please forgive me and don't forget I'm in holidays In Bourgogne (🍷=>bugs)

    posted in Pythonista read more
  • cvp

    @jm2466 this

        # 1) convert PIL Image to ui.Image
        console.hud_alert('convert PIL Image into ui.Image')
        with io.BytesIO() as bIO:
            new_im.save(bIO, 'PNG')
            ui_image = ui.Image.from_data(bIO.getvalue())
        del bIO
        # 2) Create a PHAsset from an ui.Image (not from a PIL Image)
        console.hud_alert('Create a PHAsset from an ui.Image')
        lib = PHPhotoLibrary.sharedPhotoLibrary()
        def change_block():
            req = PHAssetChangeRequest.creationRequestForAssetFromImage_(ui_image)
        def perform_changes():
            lib.performChangesAndWait_error_(change_block, None)
        t = threading.Thread(target=perform_changes)
        t.start()
        t.join()
    

    is about (😀) 1000 x slower than

        path = 'temp.jpg'
        new_im.save(path , quality=95)
        photos.create_image_asset(path)
        os.remove(path)
    

    posted in Pythonista read more
  • cvp

    @jm2466 You could always convert your PIL Image into an ui.Image and use this kind of code to save it in camera roll

    # only to have an ui.Image
    import ui
    img = ui.Image.named('test:Bridge')
    
    # Create a PHAsset from an ui.Image (not from a PIL Image)
    from objc_util import *
    import threading
    
    NSBundle.bundleWithPath_('/System/Library/Frameworks/Photos.framework').load()
    PHPhotoLibrary = ObjCClass('PHPhotoLibrary')
    PHAssetChangeRequest = ObjCClass('PHAssetChangeRequest')
    
    lib = PHPhotoLibrary.sharedPhotoLibrary()
    def change_block():
        req = PHAssetChangeRequest.creationRequestForAssetFromImage_(img)
    def perform_changes():
        lib.performChangesAndWait_error_(change_block, None)
    
    t = threading.Thread(target=perform_changes)
    t.start()
    t.join()
    

    posted in Pythonista read more
  • cvp

    @mattbellme If you want this process without any user interaction on the iPad, I don't think it is possible

    posted in Pythonista read more
  • cvp

    @jm2466 I'm in holiday, thus perhaps not able to correctly understand all (🍷🍷) but why did you not use

    photos.create_image_asset(path)
    

    instead of

    photos.save_image(Image.open(path))
    

    posted in Pythonista read more
  • cvp

    @ihf some different errors:

    • a , at end of sizes
    • bar instead of pie
    • missing explode parameter
    • explode length not ok
    import matplotlib.pyplot as plt
    
    # Pie chart, where the slices will be ordered and plotted counter-clockwise:
    labels = ['a', 'b', 'c']
    sizes = [.3, .4, .2]
    explode = [0, 0, 0 ]  # only "explode" the 2nd slice (i.e. 'Hogs')
    
    fig1, ax1 = plt.subplots()
    ax1.pie(sizes, labels=labels, autopct='%1.1f%%',
           shadow=True, startangle=90,explode=explode)
    ax1.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.
    
    plt.show()
    

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!