I was previously able to establish communication between javascript and python scripts by using a python library called Eel. However, I began to have issues with Eel when I needed to integrate it with the Electron app. So I am now trying to use sys.stdout in Electron to communicate with python script. Here is my code
Electron App
Main.js
const spawn = require("child_process").spawn
const pythonProcess = spawn('python3', ["./py/test.py"])
pythonProcess.stdout.on('data', (data) => {
mydata = data.toString()
console.log('we have data from python ',mydata)
})
function getDataFromPY(data){
console.log("i've got data")
}
test.py
def testNode():
print("node has called this python function")
def helloNode():
print("hello from python "
helloNode()
I was able to start the test.py file from the node but I want to be able to call node function from python and vice versa. What is the best method to call specific functions in node from python and vice versa in Electron framework?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…