• yes, it was a bug from me, the function works fine
    thanks

  • I've tried in ObjectiveC, following this and this

    and I have same crash with very big files of more than 25MB

    # https://gist.github.com/jsbain/389a67c5aacb097b87fd # https://github.com/tdamdouni/Pythonista/blob/master/_2017/core_image.py import ui from objc_util import * import ctypes import os iv = ui.ImageView() iv.image = ui.Image.named('P1020096.JPG') # 3888 x 2592 pixels wi,hi = iv.image.size iv.frame = (0,0,wi,hi) print(wi,hi) # 3888 2592 w = 7000 h = w*hi/wi print(w,h) # 7776 5184 with ui.ImageContext(w,h) as ctx: iv.draw_snapshot() ui_image = ctx.get_image() uio = ObjCInstance(ui_image) c.UIImageJPEGRepresentation.argtypes = [c_void_p, CGFloat] c.UIImageJPEGRepresentation.restype = c_void_p quality = 1.0 data = ObjCInstance(c.UIImageJPEGRepresentation(uio.ptr, quality)) filename = os.path.abspath('t1.jpg') data.writeToFile_atomically_(filename, True)
  • yeah, ui.in_background would work, but you might need to wrap the actual label setting in a on_main_thread, or perhaps call set_needs_display.

    the delay allows the callback to return, but then runs the other bit on the main thread, so is also good -- though no other ui will be allowed, which maybe is a good thing in this case.

    See this thread for another option -- you can define a decorator that runs a method in a nee python thread, so the convienece of a decorator but without the drawback of reponsivity issues.
    https://forum.omz-software.com/topic/3495/label-text-not-displayed-until-end-of-button-action/5

  • here is another video, technically more useful
    https://youtu.be/6Qi0UBBXZVw

  • the desired result:

    Pretty cool, isn’t it? :-)

  • @jmv38 @ccc this should be a pretty simple fix... it's been a prevalent issue for over a year now that any graphing having to do with matplotlib running on python 2.7 will crash the pythonista app. Switching to python 3 and running the script should sort any problems.

  • @jmv38 Sure that IOS11 has changed a lot in Files...

  • @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)

  • i found this link http://stackoverflow.com/questions/5640657/avfoundation-assetwriter-generate-movie-with-images-and-audio
    The very first bloc of code in this topic is sufficient i think (i dont want to alter audio).
    Is it possible to embed the whole code and pass it just the video and the image? Or do I have to call each line with objc utils?

  • thank you @omz
    so the answer to my question is (in case anyone needs it)

    mybutton.image = ui.Image("iob:arrow_resize_24")

    the [+] is quite tricky, it would be useful that when sby type 'icon' in the search filed of documentation, this information pops up (nothing pops up actually when i type 'icon').
    Thanks!

  • I would recommend removing the blanket except block at the end. The error message provided is usually less helpful than an actual traceback.

  • @jmv38 There is no way to find out what folder is currently shown in Pythonista's file list - there is no function in the editor or console module for that. It might be possible to find this out using objc_util, but I don't know Pythonista's internal structure well enough to help you with that.

  • SOLVED.
    I have modified the 1rst post code to show the solution. thanks everyone for your help.

  • Going a bit off topic (but no more than JonB already has :-) in his useful answer) I like this Github tool:

    https://github.com/Vik2015/gitrepo

    It is built with ui and is packed with features. It runs nicely as a tool action. It runs as a popup on an iPad. It will automatically use a Github url as a default value if it finds one in the clipboard, say from a google search or whatever. It allows you to browse and select from a users repositories or gists and even lets you select specific versions. I installed that single tool and was able to quickly grab a lot of productivity enhancing support tools. Especially when I found:

    https://github.com/Pythonista-Tools/Pythonista-Tools

    Which is basically a directory to a bunch of useful Pythionista stuff on Github.

    To ease installing gitrepo with its gui file authir dgelessus provides the following file in the repository which you can cut and paste into an empty python script which when run will create both needed files. That will be the last time you need to access Github by hand.

    https://github.com/Vik2015/gitrepo/blob/master/gitrepo.uipack.py
  • @ccc an @brumm i think the script SpecialButton2.py in ui-tutorial is exactly the script example i needed to start.
    Thanks a lot!

Internal error.

Oops! Looks like something went wrong!