question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make pyscript.write replace content instead of append

See original GitHub issue

I 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:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
fpligercommented, May 4, 2022

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.

0reactions
marimeirelescommented, Sep 28, 2022

This issue is going to be completely resolved by https://github.com/pyscript/pyscript/pull/749. Currently pyscript.write is deprecated and the display 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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found