1

I am using eel in order to connect the frontent(HTML,CSS and JS) and backend with Python.

I want to click the button element automatically when a if condition states to true in python.

As far as I've searched I came across Js2py to be the easiest yet it doesn't seem to work with button clicking event.

The code that I tried

js='function $fine(){document.getElementById("spl").live("click");}'
ok=js2py.eval_js(js)
ok()

Error that I got:

raise MakeError('ReferenceError', '%s is not defined' % prop) js2py.internals.simplex.JsException: ReferenceError: document is not defined

Note: The if condition that I am checking for is

if not mixer.music.get_busy()

Basically a Music player project using Pygame, the need to click the play button in order to start the next song once the current song has completed playing. I have used eel in order to get functions from python to Javascript but now I want to get Javascript functions to python without using Flask. Any suggestions would be really helpful.

gracyashhh
  • 89
  • 1
  • 11
  • suggestion: use `flask` – Matiiss Oct 25 '21 at 12:15
  • 3
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 25 '21 at 12:20
  • Using Flask will lead to changing a lot of things, I want to deploy this as a desktop application @Matiiss – gracyashhh Oct 26 '21 at 14:42
  • if it is a desktop app why even use javascript? why use web frontend? if you use web frontend you have to communicate with it in some way for example using some framework like `flask` or `django` – Matiiss Oct 26 '21 at 14:52
  • I do understand that part, I just wanted to try something different, since I heard of eel for the first time, got excited and tried this, never knew I'd even hit this kind of an hurdle.. but thought there'd be some module which could help, js2py seems to do the same but apparently doesn't work for this particular case.. hence still looking for a similar module or a way without having to change the whole project structure.. which would be a lot of work – gracyashhh Oct 26 '21 at 17:25

1 Answers1

0

UPDATE Js2Py Not working hence I tried to solve the same using Eel and faced another error as stated here but managed to solve it by doing as stated here

gracyashhh
  • 89
  • 1
  • 11