javascriptpythoneel

How to click a Button automatically with Javascript from Python using Js2py


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.


Solution

  • 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