-
In October 2022 (& later updated bokeh and panel tabulator use in early 2024) I added examples using Pandas'
read_csv()
to get and render dataframes (also using panel for rendering) based on updated pyscript using py-config now. Seepandastest.html
(working on web here) andcsv_read_display_df_with_panel.html
(working on web here; stylistically it is most like the rendering of a Pandas dataframe in Jupyter) andcsv_read_test.html
(working on web here) andcsv_read_from_same_location.html
(working on web here). In March 2024, I added a very streamlined version to demonstrate getting the CSV file using the[files]
key use as described here and here. code. Demo link. I also added a streamlined version using the[[fetch]]
feature that removes the need to rely onopen_url
directly and adds thefrom
key to specify location for fetching, see here. That iscsv_Mar_2024_fetch_test.html
(working on web here). These two approaches, with[files]
and[[fetch]]
, (with the[files]
method currently favored going forward) are meant to supercede theopen_url
method, which is illustated in the April 2023 streamlined demonstration getting the CSV file that usesopen_url
(which curiously the current demos still seem to use), seecsv_apr_2023_test.html
(working on web here). For a dataframe being printed to a terminal as well as on the page, see below under 'REPL executing code / and Terminals'. -
I added the CSV retrieval example based on
[files]
key use as described here and here and here. code . Demo link. The ones in the current (July 2024) OFFICIAL EXAMPLES (example here) don't seem to use this and still use the olderopen_url
approach, despite what was said here in May 2023 about[[fetch]]
that pre-dates[files]
.
- In April 2023, I added Matplotlib example from https://pyscript.net/examples/matplotlib.html in start of effort to update plots to current ways. See
matplotlib.html)
(working on web here). This was updated in June 2024 to add more current ways, based on the current example now here, adapted to be single-page, and this includes a...loading
screen that I left off many (all?) of my updates earlier this year in 2024 so far, see the section 'Pandas dataframe input and display'. - Based on the April 2023 update of the Matplotlib and the old version, I updated the
plot_example.html
(working on web here with specifically the '23 version) and then updated to 2024 approaches, too (working on web here. - Based on the April 2023 update of the Matplotlib and my reply to a Stackoverflow post, I added another matplotlib example,
another_plot_example.html
(working on web here with specifically the '23 version) and then updated to 2024 approaches, too (working on web here.
-
Example with only markdown cells in a notebook based on the example of Eduardo Bonet
see here to see proof using Eduoardo Bonet's approach at least for now it renders markdown from notebooks just fine (I had to remove the pyscript stuff because something was causing it to error out and not show markdown.)
-
REPL page with older pyscript: direct_example.html is based on the example this post with the code from this gist
-
terminal page: terminal_page based on November '23 and early 2024 changes terminal based on code for a terminal supplied here; I had hoped to make an interactive REPL like the code in an article detailing 'What's New in PyScript Next (2023.11.1'). Things have changed:
"PyScript no longer imports any names into the Python namespace for you. This differs from the previous release, where the names js, pyscript, Element, display, and HTML were treated a bit like builtins, and imported prior to any user-written code."
-
Another terminal page example, this one based on here with a Pandas dataframe printed to a non-interactive terminal/console as well as displayed in the main HTML: terminal_with dataframe printed to it, as well the dataframe showing in the main HTML, working on web here (code)
And I was hoping the new interactive REPL would be helpful finding things like
Element
so that I can import it. However, the interactive version failed to work like in the documentation or that article with either the 2023.11.2 or 2024.3.2 pyscript code. Or at least failed in my attempts so far. I see at https://twitter.com/JeffersGlass/status/1783116332558328178 there is an update: "There's a new release of http://pyscript.recipes today! Include fresh corrections, plus information on the py-terminal tag". And when I look at the page about , I see it warns: "The interactive REPL is only accessible when the terminal's interpreter is running in a worker." However, I don't know how to implement that worker yet. So even with new information, I think it is presently a dead end for me.
If you like Pyscript, you may also be interested in Py.cafe.
My Py.cafe gallery.
- Code in Eduoardo's example notebook runs to generate a plot
eduardo_sample_example.html works to show plot being made from the code when you click the green arrow. However, it is supposed to also be showing markdown from the notebook being rendered and that is why same example is also udner 'What doesn't work here' (Note: it looks like the posted example though and so Eduardo Bonet who posted this example was also not seeing markdown rendered even though he tried to have the javascript handle that.).
Eduoardo Bonet's approach.
Demonstrates numpy and matplotlib directly in a browser from static site.
- Plotly example makes a plot using Plotly graph objects
Based on update that doesn't allow print()
, see here, and my reply to a Stackoverflow post. The line plot, actually scatter, using Plotly graph objects works and displays but nothing happens if you click on it, which was what the OP at Stackoverflow was seeking. OP was using Plotly Express which I' not sure even works with Plotly's .on_click()
method.
-
'open_cv_demo.html' Got stuck on getting an image from URL so that I could use openCV / CV2 to manipulate it. This was starting point of an attempt to extend what I was able to do with Pyodide in JupyterLite to pyscript, see here. (This may have helped but I didn't note consulting it in code and near the end I thought I was using some of it but still no luck.) I got stuck on trying to read in the image from URL. I need to locate an example that is current and working.
I think once I got image read in I could pass the contents to numpy as an array and then cv2 can use it. I'll keep my eyes open for a modern example.
See the history for the many things I tried. -
Full example notebook of Eduardo Bonet with both code and markdown
eduardo_sample_example.html works to show plot being made from the code when you click the green arrow. However, it is supposed to also be showing markdown from the notebook being rendered. It displays and works like from his site though!! Go see it at https://eduardobonet.gitlab.io/nblite And so it isn't particular to GitHub and means he was seeing it have issues though. (By stripping out the pyscript stuff, I got the same approach to render markdown, see section 'Markdown cells from notebook do work.' and so it wasn't like it totally wasn't working. And in fact when it was failing to make markdown render fully, I'd see it render the markdown for an instant on hard refresh. And so this is probably a minor hurdle for those that know what they are doing and will get worked out soon. Note sometimes quickly entering inspection mode when trying to see what is messing up markdown rendering I'd note is showing inIt's showing in the 'Inspect' console that it is out of memory, specifically gives "WebAssembly module validated with warning: failed to allocate executable memory for module". But that didn't really seem to stop it from running the code other times when I gave it time.