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.0.tar.gz (14.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.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamlit_notify-0.3.0.tar.gz
  • Upload date:
  • Size: 14.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.0.tar.gz
Algorithm Hash digest
SHA256 da348bbc1492d5d279647f9329a7331e12421babc028b67ae6256a30f507da40
MD5 2f8771c216fb1ed401ac629592e1d05c
BLAKE2b-256 88fdbfe2b94455fa6ff9fb03af73e6aad7f8ebac521bea93b7b6296d413ce34f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_notify-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8406fc48ddb23d3b59414307b3352d6e7eeeb189f3b6063b08b8bb13624bbf37
MD5 2b715d636425277f3c01c1f4071c0b62
BLAKE2b-256 f39215513ec048e93361f4112027d61a01f1e68cc3579685af1f30c1a4502c33

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