sepal_ui.sepalwidgets.alert.Alert#

class sepal_ui.sepalwidgets.alert.Alert(**kwargs)[source]#

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.

Parameters:
  • type_ (str) – The color of the Alert

  • kwargs (optional) – any parameter from a v.Alert. If set, ‘type’ will be overwritten.

Attributes

progress_bar

the progress bar of the alert

progress_output

the output object where the progress bar is stored

Methods

__init__

A custom Alert widget.

add_live_msg

Add a message in the alert by replacing all the existing one.

add_msg

Add a message in the alert by replacing all the existing one.

append_msg

Append a message in a new parragraph, with or without divider.

check_input

Check if the inpupt value is initialized.

remove_last_msg

Remove the last msg printed in the Alert widget.

reset

Empty the messages and hide it.

update_progress

Update the Alert message with a tqdm progress bar.

Alert.__init__(type_='info', **kwargs)[source]#

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.

Parameters:
  • type_ (str) – The color of the Alert

  • kwargs (optional) – any parameter from a v.Alert. If set, ‘type’ will be overwritten.

Return type:

None

Alert.add_live_msg(msg, type_='info')[source]#

Add a message in the alert by replacing all the existing one.

Also add the timestamp of the display. The color can also be changed dynamically.

Parameters:
  • msg (str) – the message to display

  • type_ (str) – the color to use in the widget

Return type:

Self

Alert.add_msg(msg, type_='info')[source]#

Add a message in the alert by replacing all the existing one.

The color can also be changed dynamically.

Parameters:
  • msg (str) – the message to display

  • type_ (str) – the color to use in the widget

Return type:

Self

Alert.append_msg(msg, section=False, type_='info')[source]#

Append a message in a new parragraph, with or without divider.

Parameters:
  • msg (str) – the message to display

  • section (bool) – add a Divider before the added message

  • type_ (str) – the color to use in the widget

Return type:

Self

Alert.check_input(input_, msg='')[source]#

Check if the inpupt value is initialized.

If not return false and display an error message else return True.

Parameters:
  • input_ (Any) – the input to check

  • msg (str) – the message to display if the input is not set

Returns:

check if the value is initialized

Return type:

bool

Deprecated since version 3.0: This method is now part of the utils module

Alert.remove_last_msg()[source]#

Remove the last msg printed in the Alert widget.

Return type:

Self

Alert.reset()[source]#

Empty the messages and hide it.

Return type:

Self

Alert.update_progress(progress, msg='Progress', **tqdm_args)[source]#

Update the Alert message with a tqdm progress bar.

Note

set the total argumentent of tqdm to use different values than [0, 1]

Parameters:
  • progress (float) – the progress status in float

  • msg (str) – The message to use before the progress bar

  • tqdm_args (optional) – any arguments supported by a tqdm progress bar, they will only be taken into account after a call to self.reset().

Return type:

None