I am trying to write a cross-platform desktop app using web technologies (HTML5, CSS, and JS). I took a look at some frameworks and decided to use the Electron framework. >
You can use python-shell to communicate between Python and Node.js/Electron.
python-shell provides an easy way to run Python scripts from Node.js with basic and efficient inter-process communication and better error handling.
Using python-shell, you can:
In your terminal, make sure you are inside the root folder of your project and run the following command to install python-shell from npm:
npm install --save python-shell
You can then simply run a Python shell using:
var pyshell = require('python-shell');
pyshell.run('hello.py', function (err, results) {
if (err) throw err;
console.log('hello.py finished.');
console.log('results', results);
});
See more information from this tutorial