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()

# 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_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_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_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.3.1.tar.gz (15.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.3.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamlit_notify-0.3.1.tar.gz
  • Upload date:
  • Size: 15.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.3.1.tar.gz
Algorithm Hash digest
SHA256 89e2f0655059571df84952a2875ce27e6e43cfea871e69da95dfcf3a23caa445
MD5 a09f2b506f9a815d3a44bca4b3334a2b
BLAKE2b-256 9e1e2e6f3747bd98658985403ba32e8aa91bfc9f561b479c2d9450fa0537f340

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_notify-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 83154dd247a8daa70db8d254fe01247aa17c46101ccf40bb133a94dbee4fc958
MD5 edb2e360fd743b355084342143c199d2
BLAKE2b-256 bb71ce3b6c85a793f1ec2d4c4ea3b70ea5a86b7554003cc179a84fd105cc9f0f

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