Make pyscript.write replace content instead of append
See original GitHub issueI believe <py-script output="plot">...</py-script>
should replace the contents of the plot
element instead of appending.
That would make it easy to display a loading indicator as content until pyscript has loaded and run the script.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Replace and overwrite instead of appending - python
You need seek to the beginning of the file before writing and then use file.truncate() if you want to do inplace replace: import...
Read more >Completely Replace JavaScript With Python in Your HTML
In this video I take a first look at the PyScript library. This library allows you to write Python in a similar way...
Read more >Intro to PyScript: Run Python in the browser - LogRocket Blog
Let's create a Python function that prints a greeting message. In your text editor, create the main.py file and add the code below:...
Read more >7GUIs Pyscript - Explanations and Details - Jeff Glass
write () function, which takes an element_id as a string, a value to replace/append there (another string), and an optional append argument to ......
Read more >PyScript-Use Python Code in HTML - Medium
Javascript: this allows you to change CSS and HTML elements on your website after the site has been loaded. 4. How to use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a bug. I’ve added
output-mode
because I don’t think there’s a “right” or “wrong” use case. There’s a “what you’d expect for this use case” and probably any options won’t make everyone happy.With that said, the attribute is not fully hooked to the Python layer as it should.
This issue is going to be completely resolved by https://github.com/pyscript/pyscript/pull/749. Currently
pyscript.write
is deprecated and thedisplay
method will be the default way of showing elements in the UI, if you’re interested in joining the discussion to help shape the API design feel free to jump in: https://github.com/pyscript/pyscript/issues/769 I’m closing this issue because it’s not relevant anymore, but please feel free to voice opinions/concerns in the pointed issue. Cheers and thanks!