JavaScript Engine Documentation
The methods described in this page make it easy to interact with the JavaScript Engine.
- class tkinterweb.js.JSEngine(html, document, backend)
Access this class via the
javascriptproperty of theHtmlFrameandHtmlLabelwidgets.New in version 4.12.
- Variables:
html – The associated
TkinterWebinstance.document – The associated
HTMLDocumentinstance.backend – The scripting backend in use. May be
pythonmonkeyorpython. New in version 4.19.sandbox – If True, scripts running Python code will lose access to built-in objects. Default False. New in version 4.19.
- register(name, obj)
Register new JavaScript object. This can be used to access Python variables, functions, and classes from JavaScript (eg. to add a callback for the JavaScript
alert()function or add awindowAPI).JavaScript must be enabled.
- Parameters:
name (str) – The name of the new JavaScript object.
obj (anything) – The Python object to pass.
- Raises:
RuntimeError – If JavaScript is not enabled.
- eval(expr, _this=None)
Evaluate JavaScript code.
JavaScript must be enabled.
- Parameters:
expr (str) – The JavaScript code to evaluate.
- Raises:
RuntimeError – If JavaScript is not enabled.