• tbrown313

    Again, @cvp, thanks a lot for the code. Using the GUI is problematic since much of what I do involves grabbing data from a server, doing something with it, then calling another app using web browser.open(url). When that is done within a Pythonista GUI script, it leaves the GUI window running in Pythonista. My flow is like this:

    1. Run a shortcut from the Shortcuts app.
    2. Shortcut calls a Pythonista script.
    3. Pythonista script makes a remote server call to get data, perhaps display it, perhaps copy to clipboard.
    4. Pythonista script calls another app using web browser.open(url)
    5. Other app opens and I do some stuff.

    I consider this operation done, but Pythonista still has the GUI on screen if you enter the Pythonista App. So, when I do this same operation again, and the shortcut calls Pythonista, I now have two GUI windows stacked in Pythonista. This does work, but it seems clumsy and fraught with unknown problems.

    So, when I have a process like this, I have been making do with the dialogs module in Pythonista, which doesn't have this problem--but has other limitations.

    posted in Pythonista read more
  • tbrown313

    Thanks a lot for the code example, @cvp. This helps a lot. It makes it simple to figure out the best combination of font size and characters per line.

    This is probably sufficient for my purposes on the iPad since the default size is big enough. I would be interested to know how to select 'sheet', 'popover', or 'fullscreen' however. The documentation on dialogs.text_dialog() doesn't show how to do this.

    Also, if I don't have an external keyboard connected (which I never have connected on my iPhone), is there any method to get rid of the onscreen keyboard when the dialog first shows? In this particular case, I don't want the dialog text to be editable. I thought I had seen something about setting editable to false, but can't find the reference.

    posted in Pythonista read more
  • tbrown313

    Is there any way to control the size of the text_dialog?

    I have set a fixed width font for the dialog (Courier 12). On my iPad Pro the dialog width is 68 characters. However, on my iPhone 7, it is only 50.

    Is there a way to get the character size of the dialog that will be displayed?

    posted in Pythonista read more
  • tbrown313

    @ccc: Thanks for the comment. FYI, the identation in the first code block is only in this post and resulted from a copy and paste error.

    Thanks for the detail on

    with open() as

    I'm an old hardware designer who wrote a lot of internal diagnostics code that was never for production and the depth of my knowledge of such details is scant. This helps me.


    Unfortunately, I think you are correct about iCloud, and it is very disappointing. It is interesting that I have had good luck with some apps that use iCloud--like Drafts, for example--that seem much more reliable than Apple's efforts--like Notes, for example. I am going to play with storing my data in Drafts to see it that works more reliably.

    Also, as a workaround when I notice a missed update failure, I found this on the forum:


    The last comment suggests a technique to force an iCloud update in Pythonista and I have had a bit of luck with that.

    Maybe this is a question for a separate thread, but what is the effect of running a gui pythonista app multiple times from a shortcut without closing the Pythonista gui app? If I do this (my gui is less that full screen size), then the Pythonista gui app windows just stack up. Doesn't seem like a good thing, but if I handle the opening/closing of files properly, is this a problem? Of course, I wouldn't want a few hundred of them stacked up--but I would notice eventually and close them :).

    posted in Pythonista read more
  • tbrown313

    I have written a Pythonista script using the ui to create and update multiple files that are stored in the Pythonista directory of iCloud. I run the script using a shortcut and I run it from both my iPhone and my iPad.

    The problem is that when going back and forth between the iPhone and iPad accessing and modifying the same files, sometimes the files are not synchronized.

    In the Pythonista file browser, the files, and the script are in iCloud/Pythonista3/Books directory.

    For one file where I get this type of error, I open the file every time the program is run using:

    myfile = open ('CurrentBooks.txt').read()
        cBooks = json.loads(myfile)

    The file is not explicitly closed when it is only read.

    When I change the file, then I do the following:

    with open('CurrentBooks.txt', 'w') as outfile:
            json.dump(mydict, outfile)

    But I have found that, sometimes, when I add an entry to this file using the iPad, when I access the file on the iPhone, the changes are not there.

    What is going on? Is this an iCloud problem? Or am I doing something wrong in the code?

    Also, I wonder if this type of operation can get confused if the gui portion of the app is open at the same time on both devices. Since there appears to be no way to close the gui app from Pythonista, I have to remember to touch the 'X' to close the app each time I run it. I am sure that at times I have not done this.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!