Skip to main content

A notebook interface for Streamlit.

Project description

Streamlit Notebook

streamlit_notebook is a reactive notebook interface for Streamlit.

Pretty much like a Jupyter notebook, you can create and run Code cells (supporting Streamlit commands) or Markdown/HTML cells. These cells will be executed dynamically and their output will be rendered under each cell box.

The main difference with a Jupyter notebook is that the notebook is reactive: Any UI event modifying the value of a variable gets immediately reflected in the python code and vice versa.

The execution flow follows the same logic as a Streamlit script, where each cell gets re-executed from top to bottom each time the UI triggers an event. Most notably, the python session gets reinitialized every new loop and all variables/objects that have not been saved in st.session_state will be lost at the end of the current run, and redefined in the next, which is somewhat different from what one would expect in a persistent Python session.

This notebook is meant to be fully compatible with Streamlit and doesn't introduce any specific logic beyond standard Streamlit functionning. All Streamlit commands should work out of the box. If it's not the case, it should be reported as a bug.

I hope users already familiar with Streamlit will have great fun with this notebook.

Features

  • Switch to "App" mode by hiding code cells and notebook specific controls.
  • Create and delete cells easily, move cells up and down, control how they execute.
  • Create reactive Markdown or HTML cells by adding formatting tags <<my_expression>> that let you insert the current value of any global / state variable or evaluated expression into the text/code.
  • Easily download / upload your notebooks as json files.
  • The whole notebook UI can be controled dynamically from code cells. You can refer to the notebook object as st.notebook from within the session.

Screenshot

In notebook mode

In app mode

Installation

pip install streamlit-notebook

Usage

You may open a new notebook from anywhere by just running st_notebook in the terminal.

You may as well create a python file like so :

# notebook.py
from streamlit_notebook import st_notebook

st_notebook()

and run it using streamlit run notebook.py from the terminal.

The st_notebook() function imported from the package is a complete app in itself rather than a single component, and only serves as an entry point.

The app is also available online here

Contribution

This App is still in early stage of development and any feedbacks / contributions are welcome!

I think it has a lot of potential and would benefit greatly from community engagement.

In case you want to give feedback or report a bug / suggest an improvement. Please open an new issue.

If you wish to contribute to this project, please follow these instructions:

  1. Fork the repository
  2. Create a branch for your feature (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

  • june 11th 2024:
    • Added HTML cells
    • Enabled uploading / downloading the notebook as a json file
    • Added a demo notebook (more to come)
    • Fixed st.echo that didn't work in an interactive environment

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_notebook-0.0.11.tar.gz (257.0 kB view details)

Uploaded Source

Built Distribution

streamlit_notebook-0.0.11-py3-none-any.whl (307.2 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_notebook-0.0.11.tar.gz.

File metadata

  • Download URL: streamlit_notebook-0.0.11.tar.gz
  • Upload date:
  • Size: 257.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for streamlit_notebook-0.0.11.tar.gz
Algorithm Hash digest
SHA256 e548bf31f01240c0e4c1967b3a2455bc8ed7eb8b8844791d8bfd67022c0565bc
MD5 d85a40927d1fd485058a7beb3f26f2a4
BLAKE2b-256 5e9e61e5ecc81a9fa000920e060afa4f73c22e185d7ea45657bae9acfe43c121

See more details on using hashes here.

File details

Details for the file streamlit_notebook-0.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_notebook-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 3ff8402da2159cfa0d2e36f8a8e5b4f76e13c7be90d5f2332a4c2e05e3a4f385
MD5 c0243a88ab5a9acc6b3817730c57a033
BLAKE2b-256 5f70d74c8037ab64afbab560cc61b17a8d69431252ad8b33707da38e04fee927

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page