• nerdtronn

    Thanks for the replies and suggestions!

    I tried using the approach of creating SpriteNode obs for each vertical slice in the graph and setting their texture to None along with the color as desired. Then, in the update, I just loop through them and set their size to (1, desired_height) and position to the proper place.

    On initial testing I noticed artifacts, gaps occasionally between the obs on screen. I bumped the size up to (1.1, desired_height) and that fixed it. Probably rounding errors, etc. causing some gaps. With this in place, it seems to be working and pythonista doesn't crash after awhile since I'm not continually creating new path obs with every update.

    The shader approach sounds interesting, seeing that now, but haven't tried it. Will keep that in mind for the future though, maybe worth experimenting with.

    posted in Pythonista read more
  • nerdtronn

    When you exit the script and swipe over to the console you’ll see the full output.

    posted in Pythonista read more
  • nerdtronn

    Found the below thread with the solution. Just need to add @ui.in_background above the scene method definition!


    posted in Pythonista read more
  • nerdtronn

    Having trouble editing the post on mobile, but note there is the below line before getting loc1. Missed that when posting.


    posted in Pythonista read more
  • nerdtronn

    In the below script, the #1 output works as expected. The #2 output, though, called from within the scene object, does not. For #2, the location comes back correctly but the reverse geocode call always returns None. The reverse geocode doesn’t seem to work when called from scene code. Any idea how to get this to work?

    from scene import *
    import location
    class MyScene (Scene):
      def setup(self):
        loc2 = location.get_location()
        addr2 = location.reverse_geocode(loc2)
    if __name__ == '__main__':
      loc1 = location.get_location()
      addr1 = location.reverse_geocode(loc1)
      run(MyScene(), show_fps=False)

    posted in Pythonista read more
  • nerdtronn

    I have a scene based script in pythonista which displays a filled graph of values over time.

    I implemented this by creating a list of ShapeNode objects. The number of these corresponds to the width of the display area. Each one is setup with ui.Path.rect(0,0,1,height). So each one is 1 pixel wide and the height corresponds to the value being graphed for that point in time. I create the set of ShapeNode objects only once.

    Once created, on each scene update, I set the heights of all the ShapeNode objects by assigning a new ui.Path. I did this as I didn't see a way to change the height of an existing ui.Path.

    The script seems to work well. But after it runs for a bit (still trying to get more precise timing on that), pythonista exits. My thought is that reassigning a couple hundred ui.Path's on each update may be leaking something.

    My understanding is that python should gc these. Is that correct?

    1. Is there a better way to adjust the height of the shapenode after it's created?

    2. Is there some explicit call I need to release these if re-creating them each time?

    3. Any idea on how to show current memory usage for my script so I could turn this functionality on off and see if I am getting continual growth in memory?

    posted in Pythonista read more
  • nerdtronn

    Thanks for the replies! Will dig into these and see what I can get working.

    posted in Pythonista read more
  • nerdtronn

    I’d like to periodically issue an HTTP request to a URL which will return a result via JSON. This is in a scene based script. So I’d like to do it async so the scene updating doesn’t stop while the request is waiting.

    I’m new to async in python. I found asyncio and I see pythonista includes that. Many examples also use aiohttp which does not appear to be included in pythonista.

    Can anyone point me to a simple example of using asyncio only to do this which will work in a scene based script?

    posted in Pythonista read more
  • nerdtronn

    Thanks for the replies! After reading them a few times and experimenting I think I'm understanding it now.

    To create and position a rect using paths, I'm creating it with ui.Path.rect() and just giving 0,0 for the position with the desired size. Then I'm setting the position property to locate the center where I want it.

    Seems to be working, thanks for the help!

    posted in Pythonista read more
  • nerdtronn

    I’m trying to draw a box in the center of the screen using the below. The box is drawn centered about the origin (lower left corner of the screen). It doesn’t seem to respect the x and y values I’m giving it. I’m sure I’m missing something obvious :). Can anyone point me in the right direction?

    import scene as sc
    import ui
    class MyScene (sc.Scene):
      def setup(s):
        s.background_color = 'blue'
        s.bdr = sc.ShapeNode()
        s.bdr.fill_color = (0,0,0,0)
        s.bdr.stroke_color = 'yellow'
        cx = s.size.width
        cy = s.size.height
        s.bdr.path = ui.Path.rect(cx / 2, cy / 2, 100, 100)
        s.bdr.line_width = 3

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!