I'm working on an electron js application which tries to retrieve data from my python script. I managed to retrieve all of my prints in a variable but I can't manage to retrieve them one by one to display them in live on my electron app frame
thanks you very much in advance for your help.
const {PytonShell} - require('python--shell');
let options - {
pythonOptions: ['u'],
mode : 'text',
args: [args]
}
return new Promise((resolve,reject) =>{
try {
PythonShell.run('script.py', options, function (err, results) {
if (err) throw err;
var results = results.toString()
if (results.charAt(0) == "0": {
$('response').append('<div>' + results.slice(1) + '</div>')
}else if (results.charAt(0) == "1": {
$('response').append('<div>' + results.slice(1) + '</div>')
}else if (results.charAt(0) == "2": {
$('response').append('<div>' + results.slice(1) + '</div>')
}else{
console.log(results)
}
resolve();
});
}
catch{
console.log('error running python code')
reject();
}
})