Alert#
Overview#
Alert is a a custom Alert widget.
It is used as the output of all processes in the framework.
In the voila interfaces, print statement will not be displayed. Instead use the sw.Alert method to provide information to the user.
It’s hidden by default and the visibility change every time you create a message.
It inherits from the SepalWidget class.
Any argument from the original Alert ipyvuetify class can be used to complement it.
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
output = sw.Alert().show()
output
/home/docs/checkouts/readthedocs.org/user_builds/sepal-ui/envs/latest/lib/python3.10/site-packages/google/api_core/_python_version_support.py:273: FutureWarning: You are using a Python version (3.10.19) which Google will stop supporting in new releases of google.api_core once it reaches its end of life (2026-10-04). Please upgrade to the latest Python version, or at least Python 3.11, to continue receiving updates for google.api_core past that date. warnings.warn(message, FutureWarning)
Methods#
Alert object embed several methods that will be displayed in this section.
Note
More information on the methods and their options can be found in the full documentation here
update_progress#
Update the Alert message with a progress bar
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
output = sw.Alert()
add_msg#
Add a message in the alert by replacing all the existing one.
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
output = sw.Alert()
msg1 = 'lorem'
output.add_msg(msg1)
add_live_msg#
Add a message in the alert by replacing all the existing one and add a timestamp.
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
output = sw.Alert()
msg1 = 'lorem'
output.add_live_msg(msg1)
append_msg#
Append a message in a new parragraph, with or without Divider.
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
output = sw.Alert()
msg1 = 'lorem'
msg2 = 'ipsum'
output.add_msg(msg1)
output.append_msg(msg2)
remove_last_msg#
Remove the last msg printed in the Alert widget.
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
output = sw.Alert()
msg1 = 'lorem'
msg2 = 'ipsum'
output.add_msg(msg1)
output.append_msg(msg2)
output.remove_last_msg()
check_input#
Check if the inpupt value is initialized.
If not return False and display an error message else return True.
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
output = sw.Alert()
input = None
output.check_input(input)
/tmp/ipykernel_2470/592476728.py:12: DeprecationWarning: Call to deprecated method check_input. (This method is now part of the utils module) -- Deprecated since version 3.0. output.check_input(input)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[7], line 12
8 output = sw.Alert()
10 input = None
---> 12 output.check_input(input)
File ~/checkouts/readthedocs.org/user_builds/sepal-ui/envs/latest/lib/python3.10/site-packages/deprecated/classic.py:199, in ClassicAdapter.__call__.<locals>.wrapper_function(wrapped_, instance_, args_, kwargs_)
197 else:
198 warnings.warn(msg, category=self.category, stacklevel=stacklevel)
--> 199 return wrapped_(*args_, **kwargs_)
File ~/checkouts/readthedocs.org/user_builds/sepal-ui/checkouts/latest/pysepal/sepalwidgets/alert.py:249, in Alert.check_input(self, input_, msg)
236 r"""Check if the inpupt value is initialized.
237
238 If not return false and display an error message else return True.
(...)
245 check if the value is initialized
246 """
247 msg = msg or ms.utils.check_input.error
--> 249 return su.check_input(input_, msg)
File ~/checkouts/readthedocs.org/user_builds/sepal-ui/checkouts/latest/pysepal/scripts/utils.py:343, in check_input(input_, msg)
340 init = False if input_ is None else init
342 if init is False:
--> 343 raise ValueError(msg)
345 return init
ValueError: The value has not been initialized
Note
The Alert component is a key component of the tile component as it can test variable initialization, bind variable to widget, and display processes in voila dashboard. More information can be found here.