• ellie_ff1493

    I tried it with scene

    from scene import Scene, Node, LabelNode, run
    
    
    class quiz(Scene):
        def __init__(self):
            super().__init__()
            self.pages = []
            
        def setup(self):
            self.page_now = -1
            self.buttons = Node()
            self.add_child(self.buttons)
            temp = LabelNode("start quiz?")
            temp.position = self.size/2
            self.buttons.add_child(temp)
    
        def touch_began(self, touch):
            for i in self.buttons.children:
                if touch.location in i.bbox:
                    if self.page_now < len(self.pages)-1:
                        self.next_page()
                        print("userer picked:", i.text)
                    else:
                        print("end of quiz")
    
        def next_page(self):
            self.buttons.remove_from_parent()
            self.page_now += 1
            question, values = self.pages[self.page_now]
            page = Node()
            num_of_nodes = len(values) + 1
            h = self.size.h / num_of_nodes
            w = self.size.w
            x = self.size.w * 0.5
            but = LabelNode(question, font=('Helvetica', 40))
            values.append("")
            for i in range(len(values)):
                but.anchor_point = (0.5, 1)
                but.position = (x, self.size.y - (h*i))
                but.y_scale = min(w / but.size.x, h/but.size.y)
                but.x_scale = min(w / but.size.x, h/but.size.y)
                page.add_child(but)
                but = LabelNode(values[i], font=('Helvetica', 40))
    
            self.buttons = page
            self.add_child(page)
    
        def add_page(self, question, values):
            self.pages.insert(-2, (question, values))
    if __name__ == "__main__":
        app = quiz()
        app.add_page("do you like this code", ["yes", "no"])
        app.add_page("do you understand this code", ["yes", "no", "whats code lol"])
        app.add_page("if you add lots of text it gets smallergggggggggggggggggggggggggggggggggggggggg", ["oh ok, cool"])
        run(app)
    

    posted in Pythonista read more
  • ellie_ff1493

    it needs tkinter, so it won't work on pythonista

    posted in General Discussion read more
  • ellie_ff1493

    If the code is to big put it on git and add a link

    posted in General Discussion read more
  • ellie_ff1493

    What do you mean by Christians posting

    posted in General Discussion read more
  • ellie_ff1493

    It’s actually looking quite hard, how do I set a type I don’t have a reference to, I looked in the docs and it’s in a framework called simd

    posted in Pythonista read more
  • ellie_ff1493

    I made a tree drawing thing a couple of years when I saw this vid, I recommend checking out some of his other videos, they aren’t in python but it’s some really nice concepts and he explains them in terms that can translate to other languages

    from ui import ImageContext, Path, set_color, fill_rect 
    from math import  sin, cos, pi
    from random import random
    
    #help(random)
    
    
    def r(x, y, t):
    #   t = t +(random() -0.5)*0.5
        return x*cos(t) - y*sin(t), y*sin(t) + x*cos(t)
    class tree:
        def __init__(self):
            self.startlen = 50
            self.maxit = 9
            self.th = 5*pi/4
            self.thl = pi/12
            self.thr = -pi/12
            self.p = Path()
            self.short = 0.85
            self.size = 1000
            
        def draw(self):
            self.p = Path()
            self.stopn = self.startlen * (self.short ** self.maxit)
            with ImageContext(self.size, self.size) as cx:
                set_color((255,255,255))
                fill_rect(0,0,self.size, self.size)
                set_color((0,0,0))
                self.p.line_width = 0.9
                self.p.move_to(self.size/2, self.size)
                
                self.branch(self.startlen, self.size/2, self.size*4/5, 5*pi/4)
                
                self.p.stroke()
                cx.get_image().show()
                
        def branch(self, len, x, y, t):
            self.p.line_to(x, y)
            if len > self.stopn:
                self.p.move_to(x,y)
                x1, y1 = r(len, len, self.thl+t)
                self.branch(len*self.short, x+x1, y+y1, self.thl+t)
                self.p.move_to(x,y)
                x1, y1 = r(len, len, self.thr+t)
                self.branch(len*self.short, x+x1, y+y1, self.thr+t)
                
                #self.branch(len*self.short, x+x1, y+y1, self.thr+t)
            self.p.move_to(x,y)
    if __name__ == '__main__':
        s = tree()
        #s.thl += 0.25
        #for i in range(100):
        s.draw()
            
    
        
        
        
        
        
        
    

    posted in Pythonista read more
  • ellie_ff1493

    thanks, will try that and get back to you if it works

    posted in Pythonista read more
  • ellie_ff1493

    As far as I’m aware numba isn’t installed on Pythonista and can’t be installed.
    from what I understand numba makes python code run faster for data science, do you really need this on a iOS device?
    I have two suggestions.

    1. use a computer and ask the questions on stack overflow , they will be a lot more help for this

    2. use numpy, it’s installed on Pythonista

    posted in Pythonista read more
  • ellie_ff1493

    I have been trying to make noise in Pythonista but am new to objc.
    This code returns an error saying it needs 2 parameters but it needs 5 “initWithNoise_size_origin_sampleCount_seamless_”

    The documentation says 5 doc and examples to

    import objc_util
    from objc_util import *
    
    objc_util.load_framework("GameplayKit")
    GKNoise = objc_util.ObjCClass("GKNoise")
    GKNoiseMap = objc_util.ObjCClass("GKNoiseMap")
    GKPerlinNoiseSource = objc_util.ObjCClass('GKPerlinNoiseSource')
    
    noiseSource = GKPerlinNoiseSource.alloc().init()
    noiseSource.frequency = 1
    noiseSource.octaveCount = 6
    noiseSource.lacunarity = 2
    noiseSource.persistence = 0.5
    
    noise = GKNoise.alloc().initWithNoiseSource(noiseSource)#make the noise algorithem 
    
    print('initWithNoise_size_origin_sampleCount_seamless_' in dir(GKNoiseMap.alloc()))#is what im calling valid
    
    newMap = GKNoiseMap.alloc().initWithNoise_size_origin_sampleCount_seamless_(noise, (10,10),(0,0),(10,10),True)#it wants 2 but needs 5 (i tryed two, it crashs)
    
    row  = []
    for x in range(10):
        col = []
        for y in range(10):
            
            col.append(newMap.interpolatedValueAtPosition_(position=(x/10,y/10)))
        row.append(col)
        
    print(row)
    print()
    
    
    

    posted in Pythonista read more
  • ellie_ff1493

    what modules have you used?
    some are ios only (eg, ui, scene, reminders) but some are cross-platform (eg, pil, sympy, numpy, matplot)

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!