Skip to main content

streamlit-wizard

This is an example of creating a wizard within Streamlit.

To use it, create your page objects by inheriting from the Page class in components, and pass the resulting pages into the Wizard class as illustrated in main.py.

Styling

Some custom CSS styling is used for the container. You can fiddle with it in static/style.css

State

Streamlit session state is used to store the current page and to move data between pages. See example_pages.py for an example of how you can retrieve data stored on previous pages. I've not thought this pattern through very deeply, please let me know if there's a better way of doing it - obviously handling state in nested components in complex, see Redux.

Running

pip install -r requirements.txt
streamlit run main.py

Example Usage

from streamlit_wizard import components

class IntroPage(Page):
    def render(self) -> dict:
        st.title("Intro")
        st.write("This is the intro page")
        accept = st.radio(
            "Do you understand that",
            options=["Yes", "No", "Can you repeat the question"],
        )
        return dict(accept=accept)


class FirstPageOfQuestions(Page):
    def render(self) -> dict:
        st.title("Question Page")
        st.write("We will have some questions here")

        # We can access the other page state via session storage if we know what it is called
        # This is presumably not a very robust solution

        did_they_accept = st.session_state["page_state"]["intro"]["accept"]
        st.write(f"On the previous page you selected {did_they_accept}")
        fave_bean = st.selectbox(
            "What is your favourite jelly bean colour", ["Red", "Orange", "Green"]
        )
        return dict(fave_bean=fave_bean)


intro = example_pages.IntroPage(name="intro")
data = example_pages.FirstPageOfQuestions(name="questions")

wizard = components.Wizard(pages=[intro, data])

wizard.render()

Publishing

python3 -m build && python3 -m twine upload dist/*

Metadata

Release files for streamlit-wizard 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-wizard 0.0.4
File Size Uploaded Provenance
streamlit_wizard-0.0.4.tar.gz 4.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-wizard 0.0.4
File Interpreter ABI Platform
streamlit_wizard-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / streamlit_wizard-0.0.4.tar.gz

Download URL streamlit_wizard-0.0.4.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
decbada200f562e39f05c4c17b5837a76f3fae0e3ffd5b2b93f2bd3732c781db
BLAKE2b-256 checksum
How to use checksums
0f63b9098f1e03cf73c934cd0bbb0df15e21812bbd468793cb8b31aa337de23b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.4

Release files / streamlit_wizard-0.0.4-py3-none-any.whl

Download URL streamlit_wizard-0.0.4-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb4a9c675c48b05fd655e30f7d8152ddec5868d09a939704cc64bc24ac4417b1
BLAKE2b-256 checksum
How to use checksums
3728bf50f2457f9c5621cb49d4c2721b12b81de83026aaf12091a8938d446fae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.4

Security for streamlit-wizard 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page