• lukaskollmer

    Can you post the code that crashed?

    posted in Pythonista read more
  • lukaskollmer

    I noticed that the "Import file" feature of the app extension seems to be a bit inconsistent:

    When I launch the extension from the share sheet in the Photos app, the import option is hidden, while it is available when I launch the extension from Pythonistas own share sheet or an app like Transmit.

    The problem seems to be that the photos app only specifies the public.png key, while pythonista itself (and presumably Transmit as well) specify the public.file-url key.

    I think Pythonista should offer the "Import" option in both cases.

    The "Import File" option:

    The items passed to the extension:

    posted in Pythonista read more
  • lukaskollmer

    You can also use the app extension to import files into the main app

    posted in General Discussion read more
  • lukaskollmer

    If you're talking about the frames per second number in the bottom right corner, you can pass the show_fps parameter to the run function to suppress that debug output.

    Example:

    run(MyScene(), show_fps=False)
    

    posted in Pythonista read more
  • lukaskollmer

    NSURLConnection was deprecated with iOS 9. However, you can use its replacement, NSURLSession.

    This is a very basic example of how to use NSURLSession with parameters and how to get the response.
    You can pass your parameters as a dictionary as second argument to the validate method.
    I think @omz advised against using objc_util.retain_global, but it's necessary in this example to prevent the block from getting released before its getting called by the URL session.

    In a proper implementation, you probably want to create a Python class so that you can store the completion handler.

    #!/usr/bin/env python3
    import objc_util
    import urllib.parse
    from ctypes import c_void_p
    
    NSURLRequest = objc_util.ObjCClass("NSURLRequest")
    NSURLSession = objc_util.ObjCClass("NSURLSession")
    NSURLSessionConfiguration = objc_util.ObjCClass("NSURLSessionConfiguration")
    
    
    def validate(url, params, responseHandler):
        if params:
            params_encoded = urllib.parse.urlencode(params)
        else:
            params_encoded = ""
        url = objc_util.nsurl("{}?{}".format(url, params_encoded))
        request = NSURLRequest.request(URL=url)
        configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
        
        session = NSURLSession.session(Configuration=configuration)
        
        completionHandler = objc_util.ObjCBlock(responseHandler, restype=None, argtypes=[c_void_p, c_void_p, c_void_p, c_void_p])
        objc_util.retain_global(completionHandler)
        
        dataTask = session.dataTask(Request=request, completionHandler=completionHandler)
        dataTask.resume()
    
    def responseHandlerBlock(_cmd, data, response, error):
        if error is not None:
            error = objc_util.ObjCInstance(error)
            print(error)
            return
        response = objc_util.ObjCInstance(response)
        data = objc_util.ObjCInstance(data)
        print(str(objc_util.nsdata_to_bytes(data)))
    
    url = "http://validate.jsontest.com"
    params = {"json" : {"first" : "lukas", "last" : "kollmer"}}
    
    validate(url, None, responseHandlerBlock)
    

    posted in Pythonista read more
  • lukaskollmer

    @NoBetterName maximum app size shouldn't be a problem. iOS apps can be up to 4GB in size, and the app executable can be up to 60MB.

    Source: http://stackoverflow.com/a/4753253/2513803

    posted in Pythonista read more
  • lukaskollmer

    @dgelessus I know but that works fundamentally different from UIPageViewController. The page view controller pages between different independent UIViewControllers while the scroll view just displays its subviews next to each other.

    posted in Pythonista read more
  • lukaskollmer

    It'd be awesome to have a ui.PageView component in the ui module.

    A UIPageViewController is a View Controller that lets you swipe between multiple child view controllers. It displays a line of dots at the bottom to indicate the current page.
    You can also configure custom transitions for navigating between pages.

    SpringBoard (the iOS homescreen) is a good example of an UIPageViewController.

    UIPageViewController – Apple Human Interface Guidelines

    posted in Pythonista read more
  • lukaskollmer

    @omz doesn't iOS 10 require a NSAppleMusicUsageDescription entry in the Info.plist to access the MediaPlayer framework?

    posted in Pythonista read more
  • lukaskollmer

    You could host the file on a web server and use urllib.urlretrieve to download the file.

    Example:

    import urllib.request
    urllib.request.urlretrieve ("http://www.example.com/songs/mp3.mp3", "mp3.mp3")
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!