I wrote my first open-source library using nbdev: streamlit-jupyter
It allows for seamless creation of streamlit apps in jupyter notebooks.
A nifty little alternative to voila, one might say.
The way this works is it detects your environment, and if the script is run from a jupyter notebook, then it wraps existing streamlit methods to replace them with ipywidgets alternatives - that way you can code as you would in streamlit, and then displays your page as-you-code.
Then you export your notebook to a .py
file, and run it via streamlit as usual (no change in behaviour there)
Install
pip install streamlit_jupyter
How to use it
Take a look at our example notebook
The main idea is for you experiment and develop in your notebook,
visually see all the pieces, and then convert the notebook to .py
to
be run by streamlit
start by importing streamlit and patching it with streamlit-jupyter:
import streamlit as st
from streamlit_jupyter import StreamlitPatcher, tqdm
StreamlitPatcher().jupyter() # register streamlit with jupyter-compatible wrappers
And now develop your notebook as usual, but with the ability to use
Streamlit widgets and components.
See how it works below, and check out the example (it also incudes a nifty alternative to nbconvert that strips out all the magics and other irrelevant stuff)
Demonstration
|
Jupyter |
Streamlit |
Markdown and headings |
|
|
Interactive data entry |
|
|
Pick and choose |
|
|
Dataframes, caching and progress bars |
|
|
Plots |
|
|
ps
This is a very early beta and my first try at open source, so please share your thoughts and reach out with any questions/critiques!