Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何通过单击按钮从electron执行Python脚本?_Javascript_Python_Anaconda_Electron - Fatal编程技术网

Javascript 如何通过单击按钮从electron执行Python脚本?

Javascript 如何通过单击按钮从electron执行Python脚本?,javascript,python,anaconda,electron,Javascript,Python,Anaconda,Electron,try.html文件:- <html> <head> <title>Hello World!</title> </head> <body> <input type="button" class="btn" id="processbtn" value="Process" onclick="get_tt()"/> <script src="try3.js"></script>

try.html文件:-

<html>
<head>
  <title>Hello World!</title>
</head>
<body>
<input type="button" class="btn" id="processbtn" value="Process" 
 onclick="get_tt()"/>
    <script src="try3.js"></script>
  </body>
</html>

python代码未使用此代码执行。按钮的值更改为挂起,并保持不变。

你好。
hello.py
文件的内容是什么?由于您有一个
end
事件的侦听器,因此可能是您的脚本没有正确终止,并且您从未获得end事件。此外,您还可以从python文件登录到一个文件或其他类似文件,以确保调用它。您在控制台上看到任何错误吗?@limoragni hello.py:-import sys print('hello from Python!')sys.stdout.flush()Hi-KU。
hello.py
文件的内容是什么?由于您有一个
end
事件的侦听器,因此可能是您的脚本没有正确终止,并且您从未获得end事件。此外,您还可以从python文件登录到一个文件或其他类似文件,以确保调用它。您在控制台上看到任何错误吗?@limoragni hello.py:-import sys print('hello from Python!')sys.stdout.flush()
function get_tt() {
document.getElementById("processbtn").value = "Hang on..."
var python=require("python-shell")
var path = require("path")

var options = {
   scriptPath : path.join(__dirname,''),
   pythonPath : 'C:/Users/Lenovo/Anaconda3/python'
}

var f = new python("hello.py",options);
f.end(function(err, code, message) {
document.getElementById("processbtn").value = "Done";
})
}