DEV Community

David Dobrinskiy
David Dobrinskiy

Posted on

New library to develop streamlit apps in jupyter

Hey there, I created a library streamlit-jupyter to allow 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 alt alt
Interactive data entry alt alt
Pick and choose alt alt
Dataframes, caching and progress bars alt alt
Plots alt alt

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!

Top comments (0)