• Hvmhvm227

    You do know about the standard iOS screenshot by pressing the home button and the power button simultaneously?

    posted in Pythonista read more
  • Hvmhvm227

    Got it. Forgot that I wasn't drawing the images full size :-(

    posted in Pythonista read more
  • Hvmhvm227

    There seems to be a bug in image_quad regarding the 'from parameters'. I'm using this to draw part of an image as a poor mans substitute for a clipping function. Anyway, I found that when drawing an image using

    <pre>image_quad(name, 0, 0, w, 0, 0, h, w, h, 0, 0, w, 0, 0, h, w, h)</pre>
    a small portion of the image is not drawn at the top and at the right side, causing the image to be slightly zoomed. To compensate I needed to add a delta value (that seems to depend on the image size) to from_x2, from_y3, from_x4 and from_y4. (In my case the same delta for all 4 because I'm drawing squares)

    posted in Pythonista read more
  • Hvmhvm227

    @Morgan as I pointed out in the other thread, you can for the time being get around it by commenting out the long wrapping line when you want to see it entirely or edit it.

    posted in Pythonista read more
  • Hvmhvm227

    I noticed that commenting the line (e.g. Putting # at the start of the line) shows the whole line. Not ideal, but at least I can edit these long lines again...

    posted in Pythonista read more
  • Hvmhvm227

    @omz : nice app! A couple of remarks:

    Editing a workflow is a bit cumbersome. The ability to copy and paste blocks would definitely help! (Although one can misuse the custom presets for that)

    In the workflow, 'if' blocks can not be nested.

    The 'editorial://' custom URL scheme is not documented. (Unless you count the global search example). Is there a way specify in this scheme to open a document in the preview mode? (Something like 'editorial://open/file?root=somewhere&mode=preview' ?)

    The editor.to_relative_path function is not documented.

    posted in Pythonista read more
  • Hvmhvm227

    Tip: to show '<' character use '&lt;' (without the quotes)

    posted in Pythonista read more
  • Hvmhvm227

    Using pic2shop (it is strictly speaking not using the x-callback-URL mechanism, but works just fine), save the following as 'pic2shop' (without the quotes):
    <pre>
    import webbrowser
    import sys

    if len(sys.argv)>1:
    print 'Barcode:'+sys.argv[1]
    else:
    webbrowser.open('pic2shop://scan?callback=pythonista%3A//pic2shop%3Faction%3Drun%26argv%3DEAN')
    </pre>

    posted in Pythonista read more
  • Hvmhvm227

    When opening a media file (e.g. an mp4 file) in the webbrowser, the file plays just fine, but a dialog box appears on top:

    <pre>
    An error occurred while loading the page: Plug-in handled load
    </pre>

    which is not really an error. It would be great if that message didn't appear.

    posted in Pythonista read more
  • Hvmhvm227

    Added some changes, including a response and a delayed submission, so it continuously samples your location. All you have to do now is write some GPX file generation. This even works while Pythonista is in the background (although you may need to add the keep alive code (found in another thread) to keep it going). The 'Done' button now ends the capture.
    <pre>

    getGPS using html5 and interactive form

    from BaseHTTPServer import BaseHTTPRequestHandler
    from BaseHTTPServer import HTTPServer
    import cgi
    import webbrowser
    import time

    HTML = ("""<!DOCTYPE html>
    <html>
    <body>
    <p id="demo">Click the button to get your coordinates:</p>
    <form id="frm" action="/" method="POST" enctype="multipart/form-data">
    <input type="text" name="lat" id="lat" value="" />
    <input type="text" name="lng" id="lng" value="" />
    </form>
    <script>
    var frm=document.getElementById("frm");
    var lat=document.getElementById("lat");
    var lng=document.getElementById("lng");

    navigator.geolocation.getCurrentPosition(showPosition);

    function showPosition(position)
    {
    lat.value=position.coords.latitude;
    lng.value=position.coords.longitude;
    window.setTimeout(submitPosition,2000)
    }
    function submitPosition()
    {
    frm.submit()
    }
    </script>
    </body>
    </html>""")

    class RequestHandler(BaseHTTPRequestHandler):

    def do_GET(self): #load initial page
    self.send_response(200)
    self.send_header('Content-Type', 'text/html')
    self.end_headers()
    self.wfile.write(HTML)

    def do_POST(self): #process requests
    #read form data
    form = cgi.FieldStorage(fp = self.rfile, headers = self.headers,
    environ = {'REQUEST_METHOD':'POST',
    'CONTENT_TYPE':self.headers['Content-Type']})
    #assign variables
    lat = form.getfirst('lat')
    lng = form.getfirst('lng')
    print((lat,lng))
    self.send_response(200)
    self.send_header('Content-Type','text/html')
    self.end_headers()
    self.wfile.write(HTML)

    if name == 'main': #start server and open browser
    server = HTTPServer(('', 80), RequestHandler)
    webbrowser.open('http://localhost', stop_when_done = True)
    server.serve_forever()
    </pre>

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!