Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Depending on the complexity and frequency of I/O, you could just post the parameters to a python CGI script and return the result in a JSON object</p> <p>First, in JS:</p> <pre><code>function doIO (data) { var request = new XMLHttpRequest(); request.onreadystatechange = function () { if (request.readyStatus == 4) { if (request.status == 200) { alert('Success!'); var data = JSON.parse(xmlhttp.responseText); // do something with response data } else { alert('Failure'!); } } }; request.open("POST", python_cgi, true); request.send(data); } </code></pre> <p>In python you would need to implement a CGI script to parse the data, figure out the requested I/O and perform it. Your python script could be something like the following:</p> <pre><code>import cgi, json, sys form = cgi.FieldStorage() command = form.getFirst('command') if command == "filePicker": # run tkinter file picker # build json response object elif commoand == "myIoCommand": # do some I/O # build json response object print "Status: 200" print "Content-Type: application/json" json.dump(response, sys.stdout) </code></pre> <p>See for example <a href="https://developers.google.com/maps/documentation/geocoding/#JSON" rel="nofollow">Google Maps' JSON responses</a> if you need some inspiration forming your json response object.</p> <p>If you need more frequent/complex I/O, maybe what you would have to do is set up a Python server with mirrored state to your application via smaller, more frequent AJAX calls. You can use a framework to make a RESTful app, or you can roll your own by subclassing from <a href="http://docs.python.org/2/library/basehttpserver.html" rel="nofollow"><code>BaseHTTPServer</code></a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload