• AlbertoAEC

    @cvp yes, load_framework is no needed.
    Thanks to both of you for your time

    posted in Pythonista read more
  • AlbertoAEC

    @cvp @JonB THANK YOU VERY MUCH!!

    It works perfectly.
    You can try the code using other content type like phone number.

    import ui
    from objc_util import *
    UITextContentTypeOneTimeCode=c_void_p.in_dll(c, 'UITextContentTypeTelephoneNumber')
    if UITextContentTypeOneTimeCode:
        UITextContentTypeOneTimeCode = ObjCInstance(UITextContentTypeOneTimeCode)
    tf = ui.TextField()
    tf.keyboard_type = ui.KEYBOARD_NUMBER_PAD
    my_method = ObjCInstanceMethod(tfo, 'setTextContentType_')

    I couldn’t answer to you before because I was working.

    Best regards,

    posted in Pythonista read more
  • AlbertoAEC

    @mikael @cvp Thank you guys for the quick responses.

    As far as I understand, the value of the textContentType is a Structure of the type UITextContentType. I think is a internal constant but I don’t know how to get it from pythonista.

    Here is the official documentation:

    posted in Pythonista read more
  • AlbertoAEC

    I want to make a dialog that ask for a received sms code.
    The oficial form is by a parameter of the UITextField but in Pythonista there is not implemented yet. How can I make it by ObjC? I can not import UIKit by ObjCClass because Pythonista drops an error.


    Thanks you in advance.

    posted in Pythonista read more
  • AlbertoAEC

    @JonB Thank you very much for your help. Your code works perfectly. I barely had used the numpy lib and you made me a lesson of use.
    I think too the error is caused by how the version interpret the ui.Path.

    @mikael change the “centro” variable that is the center point of the 3D figure

    self.centro = np.mat([500,400,0]).T

    posted in Pythonista read more
  • AlbertoAEC

    @JonB Both problems seems to be caused by the iOS version. Before update all works perfectly. You can try the code in your own device to try something.

    Automatic rotation is already coded in the script posted above. To try it you need to make a single tap at any point of the screen.
    I post you two screenshots. First at the initial position and the second one at random angle.


    posted in Pythonista read more
  • AlbertoAEC

    @mikael Thank you, I have imagined that. I will wait for future version that fix it.

    @jgoalby said:

    Another point of reference for you. I have iOS 11 on my iPad still and it runs fine at 60fps. Sometimes goes down to 58fps when I rotate. I’ll update my iPad to iOS 12 soon and can confirm the slowness most likely.

    Yes, in previous version I had the same behaviour and it seems you will report the same slowness when you updates.

    @JonB said:

    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...

    Thank you for the info. The script was only for fun purpose and I didn’t though so much.

    posted in Pythonista read more
  • AlbertoAEC

    First of all is the first time i am writing in this forum. I want to say this app is incredible and thanks to everyone here because this site was so util for me.

    I am using this app for a year now and never I had any problems but yesterday I updated my iPad (2017 version) and script that uses Scene lib has execution problems.
    Is a script to represents some figures in 3D. Previously, with iOS 10 (iOS 11 doesn't convinced me) where I wrote the code, Pythonista ran it in 60 fps and visualice correctly a cube or a piramid (depending the uncomment lines).
    Now don't draw correctly the figures without change the code and runs in 14 fps.

    Do anyone have any idea? Thanks in advance

    from scene import *
    #import sound
    import random
    import math
    A = Action
    class Punto (SpriteNode):
        def __init__(self, r=10, *args, **kwargs):
            SpriteNode.__init__(self, 'shp:Circle', *args, **kwargs)
            self.size = (r, r)
            #self.color = random.choice(['white','yellow','blue','cyan','red','orange','purple','black','green'])
    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
    class Vector3D (object):
        def __init__(self, values):
            self.vector = values
        def to2D(self):
            elem = [[1, 0, 0],
                            [0, 1, 0]]
            return (elem[0][0] * self.vector[0] + elem[0][1] * self.vector[1] + elem[0][2] * self.vector[2],
                            elem[1][0] * self.vector[0] + elem[1][1] * self.vector[1] + elem[1][2] * self.vector[2])
        def rotateX(self, fi):
            rotMat = [[math.cos(fi), -math.sin(fi), 0],
                                [math.sin(fi), math.cos(fi), 0],
                                [0, 0, 1]]
        def rotateY(self, fi):
            rotMat = [[math.cos(fi), 0, -math.sin(fi)],
                                [0, 1, 0],
                                [math.sin(fi), 0, math.cos(fi)]]
        def rotateZ(self, fi):
            rotMat = [[1, 0, 0],
                                [0, math.cos(fi), -math.sin(fi)],
                                [0, math.sin(fi), math.cos(fi)]]
        def rotate(self, rotMat):       
            self.vector = [rotMat[0][0] * self.vector[0] + rotMat[0][1] * self.vector[1] + rotMat[0][2] * self.vector[2],
                            rotMat[1][0] * self.vector[0] + rotMat[1][1] * self.vector[1] + rotMat[1][2] * self.vector[2],
                            rotMat[2][0] * self.vector[0] + rotMat[2][1] * self.vector[1] + rotMat[2][2] * self.vector[2]]
        def center(self, centro):
            return Vector3D([self.vector[0] + centro[0], self.vector[1] + centro[1], self.vector[2] + centro[2]])
    class MyScene (Scene):
        def setup(self):
            self.angle = 0.005
            self.angleX = 0
            self.angleY = 0
            self.init_angle = self.angle
            self.centro = [500,400,0]
    #       self.p = [Vector3D([-100,-100,-100]),
    #                           Vector3D([100,-100,-100]),
    #                           Vector3D([100,100,-100]),
    #                           Vector3D([-100,100,-100]),
    #                           Vector3D([-100,-100,100]),
    #                           Vector3D([100,-100,100]),
    #                           Vector3D([100,100,100]),
    #                           Vector3D([-100,100,100])]
            self.p = [Vector3D([-100,-100,-100]),
            self.puntos = []
            for i,punto in enumerate(self.p):
            self.uniones = []
            for j in range(0,4):
                self.uniones.append(Linea(self.p[j].center(self.centro).to2D(), self.p[j+4].center(self.centro).to2D()))
            for j in range(0,3):
                self.uniones.append(Linea(self.p[j].center(self.centro).to2D(), self.p[j+1].center(self.centro).to2D()))    
            self.uniones.append(Linea(self.p[0].center(self.centro).to2D(), self.p[3].center(self.centro).to2D()))
            for j in range(4,7):
                self.uniones.append(Linea(self.p[j].center(self.centro).to2D(), self.p[j+1].center(self.centro).to2D()))    
            self.uniones.append(Linea(self.p[4].center(self.centro).to2D(), self.p[7].center(self.centro).to2D()))
            for uni in self.uniones:
        def did_change_size(self):
        def update(self):
            for p in self.p:
            for i,punto in enumerate(self.puntos):
                punto.position = self.p[i].center(self.centro).to2D()
            for j in range(0,4):
                self.uniones[j].line_path(self.puntos[j].position, self.puntos[j+4].position)
            for j in range(0,3):
                self.uniones[j+4].line_path(self.puntos[j].position, self.puntos[j+1].position)
            self.uniones[7].line_path(self.puntos[0].position, self.puntos[3].position)
            for j in range(4,7):
                self.uniones[j+4].line_path(self.puntos[j].position, self.puntos[j+1].position)
            self.uniones[11].line_path(self.puntos[4].position, self.puntos[7].position)
        def touch_began(self, touch):
            #self.angle = 0
            self.move = 0
            x, y = touch.location
            self.inicio = {'x':x, 'y':y}
        def touch_moved(self, touch):
            self.move = 1
            x, y = touch.location
            x = abs(self.inicio['x']) - abs(x)
            y = abs(self.inicio['y']) - abs(y)
            self.angleX = math.radians(x)/50
            self.angleY = math.radians(y)/50
        def touch_ended(self, touch):
            #self.angle = self.init_angle
            if self.move == 1:
                self.angleX = 0
                self.angleY = 0
                self.angleX = self.angle
                self.angleY = self.angle
    if __name__ == '__main__':
        run(MyScene(), show_fps=True)

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!