'Passing' values from python script to javascript (locally)

loveandhate80

New Member
I am trying to create/improve a microscope stage tracking system. So far I have written a python code (based on an old matlab one) which takes input from a webcam and uses it to calculate the position of the camera (and thus the stage). I now need to work out how to 'pass' data (an x and y position) to an xml file (which acts as the user interface) where certain positions can be saved etc. Currently the python script constantly updates a text file, which is then constantly read by the xml file, but I'm wondering if there is a better solution. It has been suggested to me that I create a simple, local 'web server' to host the data, but I can only find information on how to host files which would seem to defeat the purpose... Is there an easier way of doing this? Ive used python a decent amount (mainly for the numpy and scipy packages), but have little to no experience with web servers or xml...Thanksedit: I think this is the relevant part?\[code\]function getStagePos(xId,yId){ stagePosStr=getFromServer("file:///c:/stagePos.txt"); if(stagePosStr.substr(0,1)!="!"){ data=http://stackoverflow.com/questions/11276621/stagePosStr.split(","); document.getElementById(xId).value=http://stackoverflow.com/questions/11276621/data[1]; document.getElementById(yId).value=data[2]; process(); }else{ warningNode.innerHTML="Stage Position too inaccurate"; window.setTimeout('warningNode.innerHTML=""',1000); }\[/code\]edit2: sorry for not being clear, this is the 'function' of the xml file (written in javascript?) which (I think) is reading in the two fields from the stagepos.txt file. Currently,this txt file is being updated by a matlab script which I have rewritten (and improved) using python. What I am trying to ask is if there is a way to update the two fields that appear when I open the xml file (which is used to save them at certain values to 'mark' locations on the stage) without first saving them to a text file?edit3: re: changing tag from python to javascript: the code I posted is from the xml file (didnt realise It was javascript..) but my question relates to a python script which generates two constantly updating (at 30fps) fields and how to 'output' them to this file
 
Back
Top