• 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
  • lsloan117

    So, just to follow-up...

    Through some experimentation with os.getpid(), I learned that the interactive interpreter and all of my programs are running from the same process. I was surprised by this because I expected a new interpreter to start each time a program is run and it would terminate when the program does. Apparently, the way @omz implemented Pythonista, the Python interpreter isn't a subprocess, it's part of the main one and it's reset whenever a program is run. That same interpreter (or a parallel one?) handles the interactive prompt, but there's no way to reset it.

    It also appears that sys.exit() is trapped to print that EXIT (0) message. IMHO, I think the trap should reset the interpreter, if not start a new one.

    posted in Pythonista read more
  • lsloan117

    I've just started working with Pythonista and I really enjoy it. However, I wish it had better support for Dropbox (or even Google Drive) built into the editor. I've seen that support can be added using Python programs, but these require the user to get a Dropbox developer account and enter their account information and key into the program. Since this seems to be a common thing, why not make it part of Pythonista itself?

    An app I've seen recently that has good Dropbox support is Sightspace 3D (http://goo.gl/AL7jgT). After supplying this app with the user's account name and password, the contents of Dropbox are available from an item in the file loading menu. I didn't know this was possible until I saw it in this application. This is the kind of Dropbox support that Pythonista should have, too.

    Is it possible that we could see something like this in a future version of Pythonista?

    posted in Pythonista read more
  • lsloan117

    Thanks for the suggestion. It may help, but it's still rather hack-ish. I wish @omz would change Pythonista to let the Python interpreter exit as it normally would, either from a crash, a call for sys.exit(), or other appropriate method call. Then Pythonista could either start a new interpreter automatically or prompt the user to tap a button to start one.

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!