• frankL

    That's awesome! Thank you

    posted in Pythonista read more
  • frankL

    Thank you. That is cool looking. But I don't see where to input my array of paths. When I ran the script, it pulls from my camera roll.

    posted in Pythonista read more
  • frankL

    Yes, all photos in one view. Just like you see when you use
    asset = photos.pick_asset(assets)

    posted in Pythonista read more
  • frankL

    If I have the path to several photos on my iphone, for example:

    /var/mobile/Media/DCIM/131APPLE/IMG_1415.HEIC
    /var/mobile/Media/DCIM/131APPLE/IMG_1412.HEIC
    /var/mobile/Media/DCIM/131APPLE/IMG_1389.HEIC
    /var/mobile/Media/DCIM/131APPLE/IMG_1388.HEIC
    /var/mobile/Media/DCIM/131APPLE/IMG_1373.JPG

    How can I show these as thumbnails in a subview?

    posted in Pythonista read more
  • frankL

    You're right about the photo ratio. It is doing the right thing.

    I've been reading the image section in this doc:
    http://omz-software.com/pythonista/docs/ios/ui.html#image
    Which I just realized is the general section. But I found the Image module documentation (actually the list of all modules which I haven't seen before). I see that I have a lot to learn. Thanks for all of your help.

    posted in Pythonista read more
  • frankL

    That doesn't seem to change anything.

    posted in Pythonista read more
  • frankL

    That worked for displaying the photo. How would I resize the frame the same as the photo?

    posted in Pythonista read more
  • frankL

    Is this better?

    import photos
    import ui
    from objc_util import *
    import csv
    import os
    #
    def open_photo_ref():
        matrix=[]
        my_path=os.path. abspath("photo_file.csv")
        with open(my_path,'r',encoding='utf-8') as reader:
            reader=csv.DictReader(reader)
            for row in reader:
                matrix.append([row['Index'], row['Path']])
        return matrix
    #
    #
    def save_photo(photo_path):
        save_path='/private/var/mobile/Containers/Shared/AppGroup/99B62839-B39E-4ADF-9308-D5D986E28E91/Pythonista3/Documents/Frank/photo_file.csv'
        headings=['Index', 'Path']
        with open(save_path, 'w', newline='',encoding='utf-8') as out_file:
                csv.writer(out_file).writerow(headings)
                new_row = [0, photo_path]
                csv.writer(out_file). writerow(new_row)
        return
    
    
    #
    #              MAIN PROGRAM             #
    #
    #
    w, h = ui.get_screen_size()
    h -= 64
    bh = bw = 80  # label height and button width 
    mg = 10  # margin 
    view = ui.View(name='Show Photo', bg_color='#D98880', frame=(0, 0, w, h)) 
    #
    def photo_action(sender):
        matrix = open_photo_ref()
        row= matrix[0]
        my_path = row[1]
        v = ui.ImageView(frame=(0,0,500,200))
        v.image = ui.Image.named(my_path)
        v.present('sheet')
        return
    #
    photo_button = ui.Button(frame=(150,10,130,0),border_color='black', border_width=2, corner_radius = 10, tint_color = 'black', background_color='#EAECEE', action=photo_action, font=('Arial Rounded MT Bold',18)) photo_button.title='show'
    photo_button.width=100
    photo_button.height=40
    view.add_subview(photo_button)
    
    #
    def pick_action(sender):
        assets = photos.get_assets()
        asset = photos.pick_asset(assets)
        fil = str(ObjCInstance(asset).filename())
        dir = str(ObjCInstance(asset).directory())
        path = '/var/mobile/Media/' + dir + '/' + fil
        path_string = str(path)
        save_photo(path_string)
        return
    #
    pick_button = ui.Button(frame=(10,10,130,0),border_color='black', border_width=2, corner_radius = 10, tint_color = 'black', background_color='#EAECEE', action=pick_action, font=('Arial Rounded MT Bold',18)) pick_button.title='pick'
    pick_button.width=100
    pick_button.height=40
    view.add_subview(pick_button)
    
    #########################################
    nav_view = ui.NavigationView(view)
    nav_view.present('sheet')
    #########################################
    

    posted in Pythonista read more
  • frankL

    cvp, one more question: I have the following script in which I can pick a photo and save it to a csv file with a button push or show the previously saved photo with the other button push. The only problem is that I haven't been able to change the size or aspect ratio of the displayed photo. I tried setting the frame for the subview and that doesn't seem to work. How can I fix this? Thanks.

    import photos
    import ui
    from objc_util import *
    import csv
    import os
    #
    def open_photo_ref():
        matrix=[]
        my_path=os.path. abspath("photo_file.csv")
        with open(my_path,'r',encoding='utf-8') as reader:
            reader=csv.DictReader(reader)
            for row in reader:
                matrix.append([row['Index'], row['Path']])
        return matrix
    #
    #
    def save_photo(photo_path):
        save_path='/private/var/mobile/Containers/Shared/AppGroup/99B62839-B39E-4ADF-9308-D5D986E28E91/Pythonista3/Documents/Frank/photo_file.csv'
        headings=['Index', 'Path']
        with open(save_path, 'w', newline='',encoding='utf-8') as out_file:
                csv.writer(out_file).writerow(headings)
                new_row = [0, photo_path]
                csv.writer(out_file). writerow(new_row)
        return
    
    
    #
    #              MAIN PROGRAM             #
    #
    #
    w, h = ui.get_screen_size()
    h -= 64
    bh = bw = 80  # label height and button width 
    mg = 10  # margin 
    view = ui.View(name='Show Photo', bg_color='#D98880', frame=(0, 0, w, h)) 
    #
    def photo_action(sender):
        matrix = open_photo_ref()
        row= matrix[0]
        my_path = row[1]
        v = ui.ImageView(frame=(0,0,500,200))
        v.image = ui.Image.named(my_path)
        v.present('sheet')
        return
    #
    photo_button = ui.Button(frame=(150,10,130,0),border_color='black', border_width=2, corner_radius = 10, tint_color = 'black', background_color='#EAECEE', action=photo_action, font=('Arial Rounded MT Bold',18)) photo_button.title='show'
    photo_button.width=100
    photo_button.height=40
    view.add_subview(photo_button)
    
    #
    def pick_action(sender):
        assets = photos.get_assets()
        asset = photos.pick_asset(assets)
        fil = str(ObjCInstance(asset).filename())
        dir = str(ObjCInstance(asset).directory())
        path = '/var/mobile/Media/' + dir + '/' + fil
        path_string = str(path)
        save_photo(path_string)
        return
    #
    pick_button = ui.Button(frame=(10,10,130,0),border_color='black', border_width=2, corner_radius = 10, tint_color = 'black', background_color='#EAECEE', action=pick_action, font=('Arial Rounded MT Bold',18)) pick_button.title='pick'
    pick_button.width=100
    pick_button.height=40
    view.add_subview(pick_button)
    
    #########################################
    nav_view = ui.NavigationView(view)
    nav_view.present('sheet')
    #########################################
    

    posted in Pythonista read more
  • frankL

    Perfect! Thank you!

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!