|
|
|
|
|
|
|
|
|
|
|
|
|
<html> |
|
|
|
<head> |
|
<script src="pybridge.js"></script> |
|
</head> |
|
|
|
<body style="height:100px"> |
|
<input id="myinput" value="" autocomplete="off" placeholder="Enter text and press enter" /> |
|
</body> |
|
|
|
<script> |
|
var myInput = document.getElementById("myinput"); |
|
|
|
myInput.addEventListener("change", function() { |
|
|
|
sendDataToPython({ |
|
value: myInput.value, |
|
}); |
|
}) |
|
|
|
|
|
window.addEventListener("message", onDataFromPython); |
|
|
|
function onDataFromPython(event) { |
|
var data = event.data.arg; |
|
if (event.data.type !== "pypost") return; |
|
myInput.value = data.my_input_value; |
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
</html> |