Skip to main content

A Streamlit component that provides toast notifications that persist across reruns

Project description

Streamlit-Notify

A Streamlit component that provides status elements that persist across reruns.

Demo App: https://st-notify.streamlit.app/

Demo

Installation

pip install streamlit-notify

Documentation

Full documentation is available at Read the Docs.

To build the documentation locally:

cd docs
pip install -r requirements.txt
make html

Then open docs/build/html/index.html in your browser.

Supported Status Elements

  • stn.toast: Toast notifications
  • stn.balloons: Balloon animations
  • stn.snow: Snow animations
  • stn.success: Success messages
  • stn.info: Info messages
  • stn.error: Error messages
  • stn.warning: Warning messages
  • stn.exception: Exception messages

How It Works

This package wraps standard Streamlit status element to enable queueing. Notifications are stored in Streamlit's session state and displayed during the next rerun cycle.

Basic Usage

import streamlit as st
import streamlit_notify as stn

# Display all queued notifications at the beginning of your app. This will also clear the list.
stn.notify_all()

# Add a notification that will be displayed on the next rerun
if st.button("Show Toast"):
    stn.toast("This is a toast message", icon="✅")
    st.rerun()

if st.button("Show Balloons"):
    stn.balloons()
    st.rerun()

if st.button("Show Success Message"):
    stn.success("Operation successful!")
    st.rerun()

Priority Support

# Higher priority notifications are displayed first
stn.info("High priority message", priority=10)
stn.info("Low priority message", priority=-5)

Passing User Data

# Higher priority notifications are displayed first
stn.info("High priority message", data="Hello World")
stn.info("Low priority message", data={'Hello': 'World'})

Getting all notifications

# returns a dict mapping notification types to list of notifications
notifications = stn.get_all_notifications()
error_notifications = notifications['error']
toast_notifications = notifications['toast']

# or you can get the notifications directly from the stn widget
error_notifications = stn.error.get_notifications()

Clearing notifications

# clears all notifications
stn.clear_all_notifications()

# clears notifications of only a specific type
stn.error.clear_notifications()

Checking if any notifications need to be shown

# check if any notifications exist across all types
stn.has_any_notifications()

# check only specific type
stn.error.has_notifications()

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_notify-0.2.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_notify-0.2.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_notify-0.2.0.tar.gz.

File metadata

  • Download URL: streamlit_notify-0.2.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for streamlit_notify-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4aa42d6d2ab1f696663d91bd4e4d255e893248191befbcd90eb506b564b98f21
MD5 1ec6c1127585b077e3bb9ebc3999117d
BLAKE2b-256 8ec42bb4422529e267d256789742769a23c485cbcb63dabaf39f8c2326193e80

See more details on using hashes here.

File details

Details for the file streamlit_notify-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_notify-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8bf051a11e95a3774e1456fda4bd5fd255a3c1a17b721131cb5bf6cb1dff30b9
MD5 6ceade3c29d7cc2ac95eff863892f475
BLAKE2b-256 87dfc89609eb88e45122dbea04180c511fac34fefed32915a6a63d53576b46ad

See more details on using hashes here.

Supported by

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