DOM interaction questions #4733
Unanswered
ArneBachmann
asked this question in
Q&A
Replies: 2 comments 1 reply
-
You can run Python codes asynchronously and use
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you for the hint using asyncio.sleep! However, all my code is in Python, there is only one entrace point into it, so just one chance to run sync or async (and the latter never really worked).
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Very often on the first (one, two, three...) clicks on a DOM element, the event handler doesn't see node attributes that are definitely there (confirmed from the browser's dev tools), and therefore returns None/null when these attributes are queried from Python pyodide code. Some clicks later, or after clicking on another element it works again.
I have the strong feeling that the WASM Code runs in a blocking thread and doesn't see updates to the DOM, and I cannot find a programmatic way to make my code see the updated DOM while it is running.
The same problem applies when I try to dynamically create DOM nodes, and from these DOM nodes get callbacks into my code. It just doesn't seem possible.
My workaround is creating an IFRAME element before leaving the DOM gen code, which after display loads another Python callback that can then react, create more DOM + another IFRAME etc. It's a messy and slow workaround.
Is there any way to make the Python WASM code interactive with what the browser actually shows? All while not leaving the current code block.
Beta Was this translation helpful? Give feedback.
All reactions