• lsloan117

    Thanks for the info, @JonB. I hope @omz gets a chance to look into this soon.

    posted in Pythonista read more
  • lsloan117

    I'm new to Pythonista's ui module and I wonder if anybody else has seen this problem:

    I have a small program with a simple .pyui view file. The program loads the view and tries to put an image into the imageView object in the view:

    view = ui.load_view()
    imageView = view['imageview1']
    imageView.load_from_url('http://i3.kym-cdn.com/photos/images/newsfeed/000/404/302/597.gif')
    view.present()
    

    This works great the first time the program is run. However, when the program is run a second time, the entire Pythonista app freezes. I need to halt Pythonista and start it again to continue.

    I thought it might be a network issue, even though it only happens every second attempt. So I saved the image to a (very long) data URL encoded with Base64. Again, the program works the first time, but not the second time.

    If I comment out the call to load_from_url(), the rest of the program will work fine.

    I tried using an image in a much shorter URL, just in case size was the issue:

    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==
    

    However, the program exhibited the same problem.

    Should my program do some clean-up before it exits or before the image is loaded?

    Update: Here's a simple single-file program that demonstrates the problem:

    import ui
    view = ui.View()
    image = ui.ImageView()
    image.load_from_url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==')
    view.add_subview(image)
    view.present()

    posted in Pythonista read more
  • lsloan117

    I'll try that. I had glossed over the fact that it's asynchronous. I still have some questions:

    Even if it loads the image asynchronously, why would it freeze the whole app? It seems like maybe the image would fail to display when the UI is shown instead.

    Asynchronously loaded or not, any idea why it was successful the first time, but always failed the second?

    If I include images in my app encoded with Base64, they don't need to be loaded asynchronously because there's no waiting for the network. How should I put those images into the UI?

    posted in Pythonista read more
  • lsloan117

    Nice. I didn't realize View() wasn't necessary. I'm glad you're able to reproduce the problem, too.

    posted in Pythonista read more
  • lsloan117

    Oh, I see... The internal editor needs it to distinguish the type and to show the GUI editor.

    Well, I'm glad that we'll have the choice of filename extension in the future.

    Thanks!

    posted in Pythonista read more
  • lsloan117

    I was wondering, if the contents of a .pyui file is JSON, why create a special extension for it? Many editors don't know how to handle files with this extension, but if they had a ".json" extension, they are handled well. I don't think Pythonista's UI module would have trouble with that extension, either.

    Update: I see that Pythonista won't let me rename a .pyui file to .json. It changed my application and its UI file to "fubar.json.py" and "fubar.json.pyui". I guess my point is moot if Pythonista won't go along.

    posted in Pythonista read more
  • lsloan117

    I copied the comment/uncomment program from the editor module documentation. I saved it with the name "Toggle Comment", then added it to the actions menu. Whenever I select text to comment out, then tap the button for this program, it never comments the selected text. Instead, it highlights the title of the current program, as if I had tapped the rename file feature. The only time I've gotten this program to work is when I run it on itself, using the run button instead of the Actions Menu.

    Why won't it run on the text in the editor? I'm using a recent version of Pythonista with iOS v5.1.1.

    posted in Pythonista read more
  • lsloan117

    Thanks, @omz. That worked fine. I made a do-nothing program named " (Rename File)" with a leading space in the name so it would appear first.

    Will this be fixed in the next version? Any plans for when that might be released?

    posted in Pythonista read more
  • lsloan117

    How does one restart the Python interpreter in the interactive panel?

    I tried sys.exit(), which I thought would make a new one start once the current one had exited. However, it just printed "EXIT (0)" and continued running.

    posted in Pythonista read more
  • lsloan117

    I understand, @omz. You need to play by their rules.

    Could you describe what Pythonista does whenever a program is run? It seems to clear the environment first, because variables don't retain their values from one run to the next. If calls to sys.exit() are trapped, could it also clear the environment then?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!