-
Notifications
You must be signed in to change notification settings - Fork 1.5k
api reference? #1985
-
I'm really excited about pyscript, but after struggling for about 30 minutes its still not clear to me how to do very basic stuff, like manipulating a div element.
As far as I can see there's no autocomplete provided in my local editor and there's also no api reference documentation available (like what methods are available in the document
object?). Lastly the fact that there's no search on the pyscript site makes it really tricky to figure out how this thing works.
In old github issues I see links to documentation urls that no longer works - it looks like docs were more "reference-focused" earlier on?
In any case, I find this thing really interesting but sadly really hard to make sense of given the lack of documentation. It would be so cool to see that improve.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 1 reply
-
The DOM API is literally the DOM API so that everything in MDN should "just work":
https://developer.mozilla.org/en-US/docs/Web/API/Document
The same goes for elements, listeners, other APIs, in few words, the window
or the document
are exactly the same window
or document
references you would find on any standard HTML page.
If you use worker
as attribute there's not much else to add but if you don't, and you run everything on the main thread, you might need to use special pyodide features such as create_proxy
or try to see how far you can go with experimental_create_proxy = "auto"
in your <py-condifg>
tag.
Happy to help further and thanks for the ping, it's clear we should make this more clear or obvious from our current documentation.
/cc @ntoll
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for the feedback, it's really appreciated and I'm delighted you're excited by PyScript.
As @WebReflection mentions, the API for the DOM is exactly what you get on MDN and other sites describing the standard DOM API. We have an FFI layer (foreign function interface) that translates between the DOM and Python context to allow us to just access the "normal" DOM API. We discuss it in our docs here: https://pyscript.github.io/docs/2024.2.1/user-guide/dom/#ffi
The problem with the docs (and old GitHub issues), is that we radically refactored PyScript about 6months ago. It shrank from being 2mb of PyScript code, to around 30k of PyScript code. We were able to add many new features (to our pyscript
namespace, along with web workers, and other funky stuff), and the ability to use multiple Python run-times (Pyodide AND MicroPython). Sadly, the old docs are still referenced since this is a relatively recent change. However, the new docs are, well, "new" and developing, but still quite comprehensive. If in doubt the docs.pyscript.net site is where to look first, followed by asking questions in the discord channel (referenced on the front page of the docs, under "I want more support...").
We're hoping to do a "doc week" sometime soon to ensure we fold in feedback from our users, have a way for folks to contribute and improve things and make sure folks get the information they need as soon as they need it.
Hope this helps, and please keep the feedback coming. 🚀
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi thanks for taking the time to respond!
I was kindof getting the feeling that something recently got refactored, thanks for confirming :-)
I ended up trying to understand the api by looking at various examples, hoping one of them would show me what I needed. Without search, that was a really difficult thing to do.
Just as an example: I say in one demo that "display" was an importable. I thought "nice, that looks cool. Wonder what else it can do". From there I would go to https://pyscript.github.io and expect to be able to search for "display" in the top bar, or at least find a chapter called "api reference" where I could look at parameters etc for "display". I finally found it in "builtin helpers" but again without search it's not the first place I would look.
I also think the javascript-python interop deserves rich documentation and examples, since this is where (I suspect) most will be getting stuck, and the ability to reach out into javascript-based packages is such a powerful feature.
Anyway, these are just some thoughts. Really excited about pyscript!
regards,
Trond
Beta Was this translation helpful? Give feedback.