• mithrendal

    @mikael very super 👍🏿 cool indeed. I do really love your approach with this simple API. Just tried it and it works excellent. Will have a look at the source later...

    Edit: made a minor bugfix pull request to avoid an exception of being thrown

    posted in Pythonista read more
  • mithrendal

    @robertiii be aware, my code on github is still unfinished. I did this some months ago to proof that MPC is really working in Pythonista . Thats what the code does well. I uploaded it then for @mikael as an working example. But it does not yet serve as an solid and simple API, a lot of polishing and refactoring is still needed here. I am still at it, but my time for it is restricted so don't expect a finished API very soon. Of course you decide, but I would wait for @mikael 's Grand Python Simplyfication !!! That is what I am also looking forward to ;-) because he has already done some great APIs for pythonista (see here https://github.com/mikaelho).

    posted in Pythonista read more
  • mithrendal

    Hi @mikael,

    Yes that looks promising. I just uploaded my work on this for you at github. It doesn't crash and is completely reentrant. The idea was to make an simple API which games and other apps can import. But I did not work on it recently. When I saw your post that you too want to build an API I thought you might want to have a look. https://github.com/mithrendal/pythonista_mpc

    Btw I am a big fan of your Gestures.py API 😀

    posted in Pythonista read more
  • mithrendal

    Hi Mikael,

    had the same problem. The crash was caused by the garbage collection which is triggered automatically somewhen when python wants to delete the invitationHandler.

    My approach/workaround was not to get it deleted by remembering its reference. That way the garbage collector will not call delete on it.

    instead of

    blk.invoke(ObjCInstance(invitationHandler),True, ObjCInstance(mySession))


    inviHandler = ObjCInstance(invitationHandler)
    blk.invoke(inviHandler,True, ObjCInstance(mySession))

    my guess was that something in the MPC framework still holds the reference and uses this invitation handler but the pythonista garbage collector does not know this because it only knows about references in your python programm. Thus when the python gc deletes it, and after that something in the apple mpc framework wants to call it, it will inevitably crash.

    instead of someglobalscopedobject you could also use something like that to make it able to be reentrant

    import builtins

    inviHandlerObj = ObjCInstance(invitationHandler)

    if (builtins.retainCache == NONE):
       builtins.retainCache = [ ]

    blk.invoke(inviHandlerObj,True, ObjCInstance(mySession))

    posted in Pythonista read more
  • mithrendal

    I tried a mix of both suggestions with the global variable and the instance and onscreen test. But when I launch the app the second time then the global var is empty.
    Now I did the trick with the bultins class. That works fine and solves the issue nicely . Thank you so much.

    Here is the code
    import builtins

    if name == 'main':

    if(isinstance(v,ui.View) and v.on_screen ):
        #console.hud_alert('reuse view')
        #console.hud_alert('create view')
        v = ui.load_view()

    posted in Pythonista read more
  • mithrendal

    I like to know that too. Whenever I launch my ui.View app for example via url schema and it was already running then i have two views stacked on each other. I followed two approaches to solve.

    1. I start a thread and checking every second wether the app is in background. If so then I close the view. This is working but of course with the disadvantage that the view also closes when leaving pythonista for something other then restarting the script a second time.

    2. On start of my script I would try two identify all current views and close them before presenting the new view. But I did not succeed to address e.g. find the views.

    posted in Pythonista read more
  • mithrendal

    I like this too. 🤗

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!