Eel icon indicating copy to clipboard operation
Eel copied to clipboard

JS: form eel.expose(fct,name) throw a python exception

Open manatlan opened this issue 7 years ago • 6 comments

Just diving into eel ;-) BUt there is something wrong (i'm trying to call a js method, from python, in a vuejs app ... and I want to callback a component method ... so I'm trying differents approach : and found a bug)

in a vue component, in the created() event : (this works as expected )

  var self=this;
  function say_hello_js(x) {
    self.test2(x);
  }
  eel.expose(say_hello_js);  

it calls the component method (test2)

but this won't work :

  var self=this;
  function say_hello_js(x) {
    self.test2(x);
  }
  eel.expose(say_hello_js, 'say_hello_js'); 

and python side, when starting, throw :

Traceback (most recent call last):
  File "t.py", line 13, in <module>
    eel.init('web')
  File "/home/manatlan/.local/lib/python3.6/site-packages/eel/__init__.py", line 86, in init
    _mock_js_function(js_function)
  File "/home/manatlan/.local/lib/python3.6/site-packages/eel/__init__.py", line 213, in _mock_js_function
    exec('%s = lambda *args: _mock_call("%s", args)' % (f, f), globals())
  File "<string>", line 1
SyntaxError: can't assign to literal

I wanna to try to call back a component's method, from py sides ... and wanted to rename it using the eel.expose with 2 parameters ... but no luck (perhaps there is a better way ?)

If I found a patch, will push you a PR .... but I'm just evaluating eel (btw : it's really great !)

manatlan avatar Jul 19 '18 16:07 manatlan