Jupyter Display Playground
Nextjournal’s Jupyter runtimes now fully support all of Jupyter’s display kernel messages. Remix this notebook to try them out yourself.
This notebook already uses a Python Jupyter runtime. You can select a runtime’s type (e.g. Jupyter or Nextjournal) via the runtime settings menu (available from the sidebar or from the runtimes section listed at the bottom of this document).
Showing multiple results
Let’s start by running this cell to import
IPython.display and also
numpy for some of the following examples:
As you run the next cell, you will see that calling
display multiple times (each time passing a rich media/MIME bundle object) will stack corresponding results below the cell:
In addition to that, we also support changing display objects in place by calling
update on the display handle. Note that, when running the following cell, the last 🧨 from the above cell’s results will turn into a 💥.
To demonstrate a more elaborate version of this, let’s implement Conway's Game of Life based on code by @gvwilson & @jiffyclub.
First, let’s set up a function that draws the cells:
We will also need functions to evolve and advance the cells based on their neighbours:
And finally, let’s call evolve to draw the evolution:
That’s it for now. You can read up on Jupyter’s kernel display messages in the Project Jupyter Docs and if you have feedback for us, please get in touch!