• webvex34

    Here is an example interactive form application. The interface UI is driven by the built-in webserver. It's based on some of the code in Ole's file transfer script. However, in this case, the pages are served directly to the web browser component inside Pythonista. You do not need to view it from another computer--although, if you know the device's address you can do that too.

    I am a newbie to Python and GitHub, so my apologies if there are style or formatting errors. I have tested this on my iPhone and two iPads (it was written on a mini) as well as a desktop and laptop.

    I think using an HTML forms interface is a good way to produce easy to use, interactive applications. I hope this example will demonstrate some of the possibilities. Let me know what you think.

    <a href="https://gist.github.com/5ae84d7508619befd2c2">https://gist.github.com/5ae84d7508619befd2c2</a>

    Note: the gist above is now outdated. I have made a number of improvements since this initial post. Please use the newer gist shown in my second post, below.

    Larry

    posted in Pythonista read more
  • webvex34

    What's a laptop? Seriously, mine hasn't moved more than a few feet in over a year. I've had iPads since the original, and I've done all my Pythonista coding on a mini. It's quite a lifestyle change to be able to write code anywhere, waiting for an appointment, etc., places you wouldn't even have a laptop.

    I think Ole has a winner here, if he keeps it up. I worry it doesn't bring in enough money for him, though, and he has other projects. I would like to see it get more visibility. I think there are a lot of people who want/need custom applications, that can be easily distributed (for free) and quickly tweaked, but eschew the whole App Store rigmarole. Most organizations have a ton of these sort of customized scripts and in-house applications that shouldn't have to pass through Apple. More and more individuals, bloggers, etc., need personalized workflows as well.

    It will be interesting to see where apps like Pythonista and ScriptKit go, and whether Apple loosens the rules or gets in the game itself.

    posted in Pythonista read more
  • webvex34

    Serge,

    I looked at your code and Beautiful Soup a bit more today, and I agree that it is a more flexible approach (although it appears BS is geared more toward navigating/deconstructing existing HTML/XML documents). It would probably be a good strategy for a complex application with multiple screens or dynamic page elements.

    I'm a bit old school, and I like to keep everything as simple as possible. For me, and the stuff I do, it's easier to just write (and read/maintain) most of the HTML as a string. I have written functions to generate the selects, radios, etc., though, which saves quite a bit of HTML string bulk and allows creating them from lists.

    Going the BS route means creating the whole HTML document piece-by-piece. I suppose the decision comes down to whether you have more static or more dynamic elements. Or, maybe there's a hybrid solution, which seems likely—perhaps create a template of the page as a string and then use BS to manipulate only the dynamic parts.

    Either way, these types of browser-based form applications are quite useful, and not that difficult to create. Hopefully, we'll see more development and ideas like this.

    Larry

    posted in Pythonista read more
  • webvex34

    Very impressive. I'm still just learning Python and playing with the basics, although Beautiful Soup intrigues me. I will definitely look into it when/if I work with XLM, etc.

    One suggestion would be to have the entire interface run inside the browser window, instead of switching from the console for input over to the browser for output. That would be less confusing and you could run it from any other computer on the same network. It's a very cool idea, though.

    I'm also glad to see people working on productivity applications. (Multimarkdown tables are a bear to write manually.) I really think apps like Pythonista have great potential for that sort of thing.

    Thanks for sharing!

    Larry

    P.S. I also finally figured out that the following will automatically stop the script when the browser closes:

    webbrowser.open('http://localhost', stop_when_done = True)

    posted in Pythonista read more
  • webvex34

    RegExista is a simple web form–based application for manipulating text with regular expressions. You can use it just for testing REs, for learning/exploring REs, or incorporate it into a workflow by adding it to your Actions menu. It automatically loads text from the clipboard and copies the results back to the clipboard.

    I have tried to keep it very simple. Hopefully, you can figure out how it works very quickly. If you need instructions, I've failed miserably. :) And if regular expressions scare you, it works fine for just finding and replacing normal strings.

    There are only a few options: to ignore case, to replace text, and to carry over the result for multi-step operations. It also has a quick lookup drop down for some common special characters. It doesn't have all the RE flags (multiline is on) and it doesn't store REs after you've painstakingly created them. You can easily edit the drop down list in the script if you have favorites, though.

    Here is a link to the application gist:

    <a href="https://gist.github.com/0854a663e84863cc5084">https://gist.github.com/0854a663e84863cc5084</a>

    And here is a link to the required forms module (the same one used in my previous example):

    <a href="https://gist.github.com/9e2163e1041a3e17d210">https://gist.github.com/9e2163e1041a3e17d210</a>

    Larry

    P.S. Here's an example of how you could use this in a workflow, to convert tabs into spaces. Copy a script to the clipboard, open RegExista, select "Tab" from the drop down, check Replace with, and type the number of spaces you want each tab to represent (e.g. four) into the Replace with box. Press the Apply button and check the results. If it looks good, you can close RegExista and the results will be in your clipboard ready to paste back into the editor.

    posted in Pythonista read more
  • webvex34

    Thanks again. In the meantime, we can write conversion scripts and, BTW, I will be posting a new project soon that does just that sort of thing.

    posted in Pythonista read more
  • webvex34

    Thanks for the update! That will be great to have scripts run in the background, and I understand the file syncing issue. Maybe Apple will relax eventually.

    Is there any hope with the spaces vs tabs? I'm still learning Python, but from what I gather, spaces vs tabs is a bit of a hot topic. PEP 8 strongly recommends spaces only for indents in new projects, though there are arguments from both sides. Options would be nice.

    posted in Pythonista read more
  • webvex34

    My wish list:

    • Allow scripts to run in the background, even for a limited time

    • iCloud file sync (I get the Dropbox problem, but iCloud should limit it to just between Pythonista installs on multiple devices) versioning would be nice, but that can be worked around

    • Settings option for spaces instead of tabs for indents (this has been driving me crazy with errors in the editor and with Gist posts) and/or a Settings option to show whitespace characters in the editor

    posted in Pythonista read more
  • webvex34

    I have created another version of my interactive form example. This one uses an external module to create the strings for some of the HTML form elements (text box, selects, radios, checkbox). Otherwise, it runs and operates the same.

    If you don't like the idea of requiring a second file, the functions could be easily added to a single script––although, a separate module is obviously better for reuse in multiple scripts. Either way, using functions to generate some of the HTML allows for a much simpler and easier to read HTML section, and also allows you to populate the elements at run-time (e.g. from a database/web service, file, etc.).

    The idea behind the module is sort of a mini framework for simple forms-based applications. I'm not holding my breath for something like Django to be adapted for Pythonista, but it isn't very difficult to create rudimentary web applications with easy-to-use, touch–friendly interfaces.

    Here is the new application script:

    <a href="https://gist.github.com/ce21319cfe042b6013bc">https://gist.github.com/ce21319cfe042b6013bc</a>

    And here is the accompanying module:

    <a href="https://gist.github.com/9e2163e1041a3e17d210">https://gist.github.com/9e2163e1041a3e17d210</a>

    Larry

    posted in Pythonista read more
  • webvex34

    Thanks, @mcsquaredjr. I see string.replace is deprecated now. Unfortunately, using string.Template's substitute method doesn't work as neatly in some cases. I have re-written it, though, using substitute, which makes for longer (but perhaps more readable) code. Here's the link to the new version for those who might prefer it:

    <a href="https://gist.github.com/104bb2a5c79cda02cdd2">https://gist.github.com/104bb2a5c79cda02cdd2</a>

    Larry

    P.S. I cleaned up the HTML and styling a bit in this version as well.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!