I am working on my first project with pyscript and I'm trying to work with the dom. I've come across many examples that reference and import from the js package. I've tried without any luck searching for its documentation. One of the samples I've found
<py-script output="print_output">
import asyncio
from js import document, FileReader
from pyodide import create_proxy
CodePudding user response:
pyscript
is a relatively new library, and it does not have proper documentation yet. However, you can look at some examples available on the GitHub page of the pyscript
.
Here are some helpful materials: https://github.com/pyscript
- https://github.com/pyscript/pyscript/blob/main/docs/tutorials/getting-started.md
- https://github.com/pyscript/pyscript/tree/main/examples
- https://pyscript.net/examples/
Good Luck!
CodePudding user response:
JS is not a package. JS represents the namespace of JavaScript in the browser. Every function, every global variable, etc are part of the JS namespace.
From PyScript run this statement:
console.dir(js)
In the browser debugger, you can expand on that line and it will list the namespace contents. The namespace is documented by Mozilla here:
For example, console.log is part of the JS namespace (js.console). That function is documented:
Note: you will not find everything in the JS namespace documented. Programs automatically add to the namespace (application's functions and global variables).