• JonB

    Is it fair to say the the corner points seem to be behaving correctly, and the lines have the correct angles, however the line positions appear incorrect?

    One problem I see is that you should not be using update. This calls the function even if it is not needed. Instead, rename it to update_points and call that from touch_moved and touch_ended.

    A second issue is that you are creating many, many Vector3D objects, since .center() creates new instances. Might be a memory problem.

    As a debug, maybe you can change Linea as follows, and see if the orig/dest are being set correctly (this adds a label to the center of each line).

    class Linea (ShapeNode):
        def __init__(self, orig, dest, *args, **kwargs):
            ShapeNode.__init__(self, *args, **kwargs)
            self.line_path(orig, dest)
            self.stroke_color = '#ffffff'
        def line_path(self, orig, dest):
            x1,y1 = orig
            x2,y2 = dest
            self.position=((x2-x1)/2. + x1, (y2-y1)/2. + y1)
            path = ui.Path()
            path.line_width = 2
            self.path = path

    I suspect the issue has something to do with how Paths auto reset the bounds, which the original code depends on. Maybe ios12 behaves differently.
    Finally, here is a numpy'd version of the code. Does this work for you, and is it faster?


    posted in Pythonista read more
  • JonB

    fwiw, requests lets you use req.json() rather than json.loads(req.contents). also, you can use json=values instead of json.dumps(values) in the request.

    posted in Pythonista read more
  • JonB

    When you say that, in addition to slowness, the picture does not look corredt, can you post a screenie? maybe if we can figure out the cause of the drawing error, we will get to the cause of the slowness.

    Does the initial picture, before using touch look ok?
    Could you try using update to rotate directly, without using touch?
    If those are messed up, then you can set a specific rotation angle, and dump out the points and rotation matricies, and we can check against the theoretical.

    posted in Pythonista read more
  • JonB

    so, did you try the bytesio code, followed by b64encode? Post that completed attempt, then we can work from there. You might need to pass that through .decode('ascii') after that. you might need json= instead of data=.

    I found a complete python api:


    which uses those two other modifications I mentioned (they read the file directly, but the important thing is just getting the bytes out into b64encode)

    posted in Pythonista read more
  • JonB

    he is getting an error during import.

    This was previously discussed on the forum, and in that case it was a failed import, fixed by a force quit of pythonista


    posted in Pythonista read more
  • JonB

    Out of curiosity, have you tried writing this as numpy arrays? You can transform all of the points at the same time, should be a lot faster...

    posted in Pythonista read more
  • JonB

    A common approach is to use BytesIO:

    import io
    with io.BytesIO() as output:
        contents = output.getvalue()

    You might need to then pass contents through base64.b64encode

    posted in Pythonista read more
  • JonB

    Did you try to a numpy update ? That causes problems since you cannot update numpy.

    The other problem people have is that since numpy can take a while to load, if you can cancel a script, it might be only partially imported. Try force quitting the app and try again.

    If that doesn't work, push the Print Traceback button, and paste the full Traceback to the forum.

    posted in Pythonista read more
  • JonB

    Guys, this is what insert_rows is for! Don't use reload_table!

    posted in Pythonista read more
  • JonB

    This is a very well known problem:

    pandas does not work in pythonista. You cannot install it.

    You may have also tried to install numpy, which is already installed and cannot be reinstalled. Go to your site-packages-3 and site-packages folder and delete any numpy folders you see.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!