streamlit_notify
Initialization module for the st_notify package.
- class streamlit_notify.RerunnableStatusElement(base_widget)[source]
Bases:
objectA wrapper for Streamlit widgets to enable notification queueing.
Initialize the wrapper.
- property notifications: NotificationPriorityQueue
Get the notification queue.
- create_notification(*args, **kwargs)[source]
Create a notification without adding it to the queue.
- Parameters:
- Return type:
- streamlit_notify.create_notification(*args, **kwargs)[source]
Create a notification without adding it to the queue.
- Parameters:
- Return type:
- streamlit_notify.notify(notification_type=None, remove=True, priority=None, priority_type='ge')[source]
Display queued notifications.
- Parameters:
notification_type (Literal['toast', 'balloons', 'snow', 'success', 'info', 'error', 'warning', 'exception'] | ~typing.Iterable[~typing.Literal['toast', 'balloons', 'snow', 'success', 'info', 'error', 'warning', 'exception']] | None)
remove (bool)
priority (int | None)
priority_type (Literal['le', 'ge', 'eq'])
- Return type:
None
- streamlit_notify.get_notifications(notification_type=None, priority=None, priority_type='ge')[source]
Retrieve all notifications for a specific type(s).
- Parameters:
- Return type:
- streamlit_notify.clear_notifications(notification_type=None)[source]
Clear notifications for a specific type(s).
- Parameters:
notification_type (Literal['toast', 'balloons', 'snow', 'success', 'info', 'error', 'warning', 'exception'] | ~typing.Iterable[~typing.Literal['toast', 'balloons', 'snow', 'success', 'info', 'error', 'warning', 'exception']] | None)
- Return type:
None
- streamlit_notify.get_notification_queue(notification_type)[source]
Retrieve notification priority queue.
- Parameters:
notification_type (Literal['toast', 'balloons', 'snow', 'success', 'info', 'error', 'warning', 'exception'])
- Return type:
- streamlit_notify.has_notifications(notification_type=None)[source]
Check if there are any notifications.
- streamlit_notify.remove_notifications(notifications)[source]
Remove notification(s) from the queue.
- Parameters:
notifications (StatusElementNotification | Iterable[StatusElementNotification])
- Return type:
None
- streamlit_notify.add_notifications(notifications)[source]
Add notification(s) to the queue.
- Parameters:
notifications (StatusElementNotification | Iterable[StatusElementNotification])
- Return type:
None
- class streamlit_notify.NotificationPriorityQueue(queue_name, sort_func=None)[source]
Bases:
objectA Priority queue for managing Streamlit notifications.
Initialize the queue.
- Parameters:
queue_name (str)
sort_func (Callable[[StatusElementNotification], int] | None)
- __init__(queue_name, sort_func=None)[source]
Initialize the queue.
- Parameters:
queue_name (str)
sort_func (Callable[[StatusElementNotification], int] | None)
- Return type:
None
- property queue: List[StatusElementNotification]
Get the current queue.
- property sort_func: Callable[[StatusElementNotification], int]
Get the sorting function for the queue.
- append(item)[source]
Add an item to the queue.
- Parameters:
item (StatusElementNotification)
- Return type:
None
- extend(items)[source]
Add multiple items to the queue.
- Parameters:
items (Iterable[StatusElementNotification])
- Return type:
None
- remove(item)[source]
Remove an item from the queue.
- Parameters:
item (StatusElementNotification | int)
- Return type:
None
- contains(item)[source]
Check if an item is in the queue.
- Parameters:
item (StatusElementNotification)
- Return type:
- _get_all_less_than(priority)[source]
Get all items in the queue with priority less than the specified value.
- Parameters:
priority (int)
- Return type:
- _get_all_less_than_equal_to(priority)[source]
Get all items in the queue with priority less than or equal to the specified value.
- Parameters:
priority (int)
- Return type:
- _get_all_greater_than(priority)[source]
Get all items in the queue with priority greater than the specified value.
- Parameters:
priority (int)
- Return type:
- _get_all_greater_than_equal_to(priority)[source]
Get all items in the queue with priority greater than or equal to the specified value.
- Parameters:
priority (int)
- Return type:
- _get_all_equal_to(priority)[source]
Get all items in the queue with priority equal to the specified value.
- Parameters:
priority (int)
- Return type:
- get_all(priority=None, priority_type='eq')[source]
Get all items in the queue.
- Parameters:
- Return type:
- get(index=0)[source]
Get an item from the queue without removing it.
- Parameters:
index (int)
- Return type:
- __contains__(item)[source]
Check if an item is in the queue.
- Parameters:
item (StatusElementNotification)
- Return type:
- __setitem__(index, value)[source]
Set an item by index.
- Parameters:
index (int)
value (StatusElementNotification)
- Return type:
None
- __iter__()[source]
Iterate over the notifications in the queue.
- Return type:
Generator[StatusElementNotification, None, None]
- __reversed__()[source]
Iterate over the notifications in reverse order.
- Return type:
Generator[StatusElementNotification, None, None]
- class streamlit_notify.StatusElementNotification(base_widget, args, priority=0, data=None)[source]
Bases:
objectRepresents a notification for a Streamlit widget.
- Parameters:
- args: OrderedDict[str, Any]
- class streamlit_notify.NotificationType(value)[source]
Bases:
EnumEnum class for notification types.
- TOAST = 'toast'
- BALLOONS = 'balloons'
- SNOW = 'snow'
- SUCCESS = 'success'
- INFO = 'info'
- ERROR = 'error'
- WARNING = 'warning'
- EXCEPTION = 'exception'
- streamlit_notify.get_status_element(notification_type)[source]
Get the Streamlit status element corresponding to the notification type.
- Parameters:
notification_type (NotificationType | str)
- Return type:
- streamlit_notify.init_session_state()[source]
Initialize session state for all notification elements.
- Return type:
None
- streamlit_notify.__getattr__(name)[source]
Delegate attribute access to Streamlit if not found in this module.
This function is not included in type checking to prevent it from appearing in stub files.
- Args:
name: Name of the attribute to get.
- Returns:
The requested attribute from Streamlit.
- Raises:
AttributeError: If the attribute is not found in Streamlit.