• bg2b

    Is there an up-to-date summary of the idea for packaging up a Pythonista project to make an app? I see that the template linked from

    https://forum.omz-software.com/topic/1911/new-xcode-template-beta

    doesn't exist anymore, and I'm not sure where to begin learning.

    posted in Pythonista read more
  • bg2b

    The appex resource limits would explain everything. I don’t have Xcode access to check, but it makes sense. Thanks for helping out a Pythonista newbie!

    posted in Pythonista read more
  • bg2b

    I've got a little script for making half-size screenshots that I'd like to use as an appex. When I invoke the script normally, it pops up a photo selector and everything works fine. If I go into my screenshots album, select some photos, and then try to invoke the script via the appex mechanism, it processes a few photos (typically 3-6) and then the Pythonista window closes with no further indication of what has happened. It's not deterministic; if I delete the partial results and go back and try it again with the exact same photos, sometimes it will work. Here's a little YouTube video showing what happens. There's no information left the the console unfortunately. I also tried enabling the faulthandler, but there's nothing written to the file that I give it. I've added various tweaks thinking that maybe there was some kind of race condition, things like writing the PNG files to separate filenames or putting a one second sleep at various spots. None of those made any difference. I'm at a bit of a loss right now, so any suggestions for what might be wrong or how to proceed in debugging would be welcome.

    import photos
    import appex
    import datetime
    from PIL import Image
    
    def main():
      if appex.is_running_extension():
        imgs=appex.get_images()
      else:
        screenshots=photos.get_screenshots_album()
        assets=photos.pick_asset(assets=screenshots, title='Select screenshots to shrink', multi=True)
        if assets:
          imgs=[a.get_image() for a in assets]
        else:
          imgs=[]
      if not imgs:
        print('No input screenshots')
        return
      album_name='Small Screenshots'
      albums=[a for a in photos.get_albums() if a.title == album_name]
      if albums:
        album=albums[0]
      else:
        album=photos.create_album(album_name)
      for (i, img) in enumerate(imgs):
        print(f'Shrinking screenshot number {i+1}...')
        size=img.size
        small_img=img.resize((size[0]//2, size[1]//2), Image.BILINEAR)
        filename='.temp.png'
        with open(filename, 'wb') as f:
          small_img.save(f, 'PNG')
        asset=photos.create_image_asset(filename)
        album.add_assets([asset])
        asset.creation_date=datetime.datetime.now()
      print('Done!')
    
    if __name__ == '__main__':
      main()
    
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!