• omz

    I'm making progress... There's still a lot left to do, but it's looking good so far.

    posted in Pythonista read more
  • omz

    This is a bug in the example, sorry, It should work if you just replace v with widget_view.

    posted in Pythonista read more
  • omz

    @jmv38 This is the best I could come up with:

    import appex
    import photos
    from objc_util import ObjCInstance
    
    def assets_for_attachments(attachments):
        all_assets = photos.get_assets()
        matching_assets = []
        for a in all_assets:
            objc_asset = ObjCInstance(a)
            path_orig = str(objc_asset.pathForOriginalFile())
            path_edit = str(objc_asset.pathForFullsizeRenderImageFile())
            if path_orig in attachments or path_edit in attachments:
                matching_assets.append(a)
        return matching_assets
    
    attachments = appex.get_attachments()
    assets = assets_for_attachments(attachments)
    # Now you can use the photos module to manipulate the assets...
    

    posted in Pythonista read more
  • omz

    This is the bookmark bar (which can include workflow shortcuts), but this feature is only available on iPad.

    posted in Editorial read more
  • omz

    No need for objc_util, you can use JavaScript:

    selected_text = web_view.eval_js('document.getSelection().toString()')
    

    posted in Pythonista read more
  • omz

    If you really need to modify photos from the app extension, here's a hackish way you could do that. It's somewhat slow, and relies on undocumented (private) API, but it should work:

    import appex
    import photos
    from objc_util import ObjCInstance
    
    def assets_for_attachments(attachments):
        all_assets = photos.get_assets()
        matching_assets = []
        for a in all_assets:
            path = str(ObjCInstance(a).pathForOriginalFile())
            if path in attachments:
                matching_assets.append(a)
        return matching_assets
    
    attachments = appex.get_attachments()
    assets = assets_for_attachments(attachments)
    # Now you can use the photos module to manipulate the assets... (as in previous example)
    

    posted in Pythonista read more
  • omz

    You cannot modify a photo in-place that was passed to the app extension.

    You can however use the photos module for that. Here's a simple example that lets you pick a photo, and set its creation date with a date picker:

    import photos, dialogs
    
    asset = photos.pick_asset()
    new_date = dialogs.datetime_dialog('Set Creation Date')
    asset.creation_date = new_date
    

    posted in Pythonista read more
  • omz

    I'd recommend setting the scale attribute. Setting the size (as @ccc has shown) would also work, but you would need to set it again when you change the texture of a sprite.

    It might actually be easier to set the scale of the entire scene instead of scaling each card individually.

    posted in Pythonista read more
  • omz

    @krizex Pythonista itself doesn't use the iAd framework, so you'd have to load it first:

    objc_util.load_framework('iAd')
    

    I think this function is undocumented, it's equivalent to:

    objc_util.ObjCClass('NSBundle').bundleWithPath_('/System/Frameworks/iAd.framework').load()
    

    posted in Pythonista read more
  • omz

    If your search term contains spaces, or other characters that aren't allowed in a URL, you'll need to quote them, e.g. foo bar => foo%20bar.

    import urllib.parse
    search_term = urllib.parse.quote(sender.text, '')
    webview.load_url('https://www.google.com/search?q=' + search_term)
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!