Closed sooraj-sn closed 3 years ago
Please help in getting the correct value
the trick is to make your function displaygraph async, and await eel.GetPath()()
(note the double parentheses).
So, your python code stays
@eel.expose
def GetPath():
return "C:/Adds"
But your javascript code should be:
async function displaygraph() {
var data = document.getElementById("counter_name").value;
document.getElementById("frame").src = await eel.GetPath()();
}
See this example, or alternatively you can also include a callback like in this example
@eel.expose def GetPath(): return "C:/Adds"
function displaygraph() { var data = document.getElementById("counter_name").value document.getElementById("frame").src = eel.GetPath() }
the return value is some function and not the string expected:
Result : http://localhost:8000/function%28callback%20%3D%20null%29%20%7B%20%20%20%20%20%20%20%20%20%20%20%20if%28callback%20%21%3D%20null%29%20%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20eel._call_return_callbacks%5Bcall.call%5D%20%3D%20%7Bresolve%3A%20callback%7D%3B%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20return%20new%20Promise%28function%28resolve%2C%20reject%29%20%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20eel._call_return_callbacks%5Bcall.call%5D%20%3D%20%7Bresolve%3A%20resolve%2C%20reject%3A%20reject%7D%3B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%29%3B%20%20%20%20%20%20%20%20%20%20%20%20%7D%20%20%20%20%20%20%20%20%7D'