Skip to content

Compute widgets

ComputeWidgetsMixin

button staticmethod

button(key, on_click=None, args=None, kwargs=None, label='Click Me', show=True, help_text='')

Create a button widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

on_click

Optional[Callable]

Callback function for the button. Defaults to None.

None

args

Optional[Tuple]

Arguments for the callback function. Defaults to None.

None

kwargs

Optional[dict]

Keyword arguments for the callback function. Defaults to None.

None

label

str

Label for the button. Defaults to "Click Me".

'Click Me'

show

bool

Whether to show the widget in the report. Defaults to True.

True

help_text

str

Help text for the button. Defaults to "".

''

Returns:

Name Type Description
bool bool

Whether the button was clicked.

checkbox staticmethod

checkbox(key, label='', value=False, disabled=False, description='', reference='', show=True, help_text='', helper_images=None)

Create a checkbox widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

label

str

Label for the widget. Defaults to "".

''

value

bool

Default value. Defaults to False.

False

disabled

bool

Whether the widget is disabled. Defaults to False.

False

description

str

Description of the widget. Defaults to "".

''

reference

str

Reference for the widget. Defaults to "".

''

show

bool

Whether to show the widget in the report. Defaults to True.

True

help_text

str

Help text for the widget. Defaults to ''.

''

helper_images

Optional[List[WidgetHelperImage]]

List of helper images for the widget. Defaults to None.

None

Returns:

Name Type Description
bool bool

The value of the checkbox.

data_filter staticmethod

data_filter(key, file_name, filter_columns, is_local=False, label='', value=None, disabled=False, description='', reference='', show=True, help_text='')

Create a data filter widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

file_name

str

Name of the file to filter.

required

filter_columns

List[str]

List of columns to filter.

required

is_local

bool

Whether the file is local. Defaults to False.

False

label

str

Label for the widget. Defaults to "".

''

value

Optional[List[str]]

Default value. Defaults to None.

None

disabled

bool

Whether the widget is disabled. Defaults to False.

False

description

str

Description of the widget. Defaults to "".

''

reference

str

Reference for the widget. Defaults to "".

''

show

bool

Whether to show the widget in the report. Defaults to True.

True

help_text

str

Help text for the widget. Defaults to ''.

''

Returns:

Type Description
List[str]

List[str]: The filtered data.

download_button staticmethod

download_button(key, file, label='Download File', on_click=None, args=None, kwargs=None, show=True, help_text='')

Create a download button widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

file

FileData

File to be downloaded.

required

label

str

Label for the button. Defaults to "Download File".

'Download File'

on_click

Optional[Callable]

Callback function for the button. Defaults to None.

None

args

Optional[Tuple]

Arguments for the callback function. Defaults to None.

None

kwargs

Optional[dict]

Keyword arguments for the callback function. Defaults to None.

None

show

bool

Whether to show the widget in the report. Defaults to True.

True

help_text

str

Help text for the button. Defaults to "".

''

Returns:

Name Type Description
bool bool

Whether the button was clicked.

file_uploader staticmethod

file_uploader(key, label='', value=None, max_size_mb=20, allowed_extensions=None, is_multiple=False, disabled=False, description='', reference='', show=True, help_text='')

Create a file uploader widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

label

str

Label for the widget. Defaults to "".

''

value

None | FileData | List[FileData]

Default value. Defaults to None.

None

max_size_mb

int

Maximum file size allowed in MB. Defaults to 20.

20

allowed_extensions

Optional[List[str]]

List of allowed file extensions. Defaults to None.

None

is_multiple

bool

Whether multiple files can be uploaded. Defaults to False.

False

disabled

bool

Whether the widget is disabled. Defaults to False.

False

description

str

Description of the widget. Defaults to "".

''

reference

str

Reference for the widget. Defaults to "".

''

show

bool

Whether to show the widget in the report. Defaults to True.

True

help_text

str

Help text for the widget. Defaults to ''.

''

Returns:

Type Description
None | FileData | List[FileData]

None | FileData | List[FileData]: The uploaded file(s). If no file is uploaded, returns None. If a single file is uploaded (is_multiple=False), returns a FileData object. If multiple files are uploaded (is_multiple=True), returns a list of FileData objects.

multiselect staticmethod

multiselect(key, options, value=None, label='', disabled=False, description='', reference='', show=True, help_text='', helper_images=None)

Create a multiselect widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

options

List[str] | List[NumericValueT]

List of options for the multiselect.

required

value

Optional[List[str] | List[NumericValueT]]

Default selected values. Defaults to None.

None

label

str

Label for the widget. Defaults to "".

''

disabled

bool

Whether the widget is disabled. Defaults to False.

False

description

str

Description of the widget. Defaults to "".

''

reference

str

Reference for the widget. Defaults to "".

''

show

bool

Whether to show the widget in the report. Defaults to True.

True

help_text

str

Help text for the widget. Defaults to ''.

''

helper_images

Optional[List[WidgetHelperImage]]

List of helper images for the widget. Defaults to None.

None

Returns:

Type Description
List[str] | List[NumericValueT]

List[str] | List[NumericValueT]: The selected values.

number_input staticmethod

number_input(key, min_val, max_val, step, label='', value=None, disabled=False, description='', reference='', unit='', format_str='{:.2f}', show=True, help_text='', helper_images=None)

Create a number input widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

min_val

NumericValueT

Minimum value allowed.

required

max_val

NumericValueT

Maximum value allowed.

required

step

NumericValueT

Step size for the input.

required

label

str

Label for the widget. Defaults to "".

''

value

Optional[NumericValueT]

Default value. Defaults to None.

None

disabled

bool

Whether the widget is disabled. Defaults to False.

False

description

str

Description of the widget. Defaults to "".

''

reference

str

Reference for the widget. Defaults to "".

''

unit

str

Unit of the value. Defaults to "".

''

format_str

str

Format string for the value. Defaults to '{:.2f}'.

'{:.2f}'

show

bool

Whether to show the widget. Defaults to True.

True

help_text

str

Help text for the widget. Defaults to ''.

''

helper_images

Optional[List[WidgetHelperImage]]

List of helper images for the widget. Defaults to None.

None

Returns:

Name Type Description
NumericValueT NumericValueT

The value of the widget.

selectbox staticmethod

selectbox(key, options, value=None, label='', disabled=False, description='', reference='', show=True, help_text='', helper_images=None)

Create a selectbox widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

options

List[str] | List[NumericValueT]

List of options for the selectbox.

required

value

Optional[str | NumericValueT]

Default selected value. Defaults to None.

None

label

str

Label for the widget. Defaults to "".

''

disabled

bool

Whether the widget is disabled. Defaults to False.

False

description

str

Description of the widget. Defaults to "".

''

reference

str

Reference for the widget. Defaults to "".

''

show

bool

Whether to show the widget in the report. Defaults to True.

True

help_text

str

Help text for the widget. Defaults to ''.

''

helper_images

Optional[List[WidgetHelperImage]]

List of helper images for the widget. Defaults to None.

None

Returns:

Type Description
str | NumericValueT

str | NumericValueT: The selected value.

slider staticmethod

slider(key, min_val, max_val, step, label='', value=None, disabled=False, description='', reference='', unit='', format_str='{:.2f}', show=True, help_text='', helper_images=None)

Create a slider widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

min_val

NumericValueT

Minimum value allowed.

required

max_val

NumericValueT

Maximum value allowed.

required

step

NumericValueT

Step size for the slider.

required

label

str

Label for the widget. Defaults to "".

''

value

Optional[NumericValueT]

Default value. Defaults to None.

None

disabled

bool

Whether the widget is disabled. Defaults to False.

False

description

str

Description of the widget. Defaults to "".

''

reference

str

Reference for the widget. Defaults to "".

''

unit

str

Unit of the value. Defaults to "".

''

format_str

str

Format string for the value. Defaults to '{:.2f}'.

'{:.2f}'

show

bool

Whether to show the widget. Defaults to True.

True

help_text

str

Help text for the widget. Defaults to ''.

''

helper_images

Optional[List[WidgetHelperImage]]

List of helper images for the widget. Defaults to None.

None

Returns:

Name Type Description
NumericValueT NumericValueT

The value of the widget.

table_input staticmethod

table_input(key, col_formats, label='', min_rows=1, max_rows=100, is_file=False, value=None, disabled=False, description='', reference='', show=True, help_text='')

Create a table input widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

col_formats

List[ColumnFormatBase]

List of column formats for the table.

required

label

str

Label for the widget. Defaults to "".

''

min_rows

int

Minimum number of rows allowed. Defaults to 1.

1

max_rows

int

Maximum number of rows allowed. Defaults to 100.

100

is_file

bool

Whether the input is a file. Defaults to False.

False

value

Optional[List[List]]

Default value. Defaults to None.

None

disabled

bool

Whether the widget is disabled. Defaults to False.

False

description

str

Description of the widget. Defaults to "".

''

reference

str

Reference for the widget. Defaults to "".

''

show

bool

Whether to show the widget in the report. Defaults to True.

True

help_text

str

Help text for the widget. Defaults to ''.

''

Returns:

Type Description
List[List]

List[List]: The value of the table input.

text_input staticmethod

text_input(key, label='', max_chars=100, max_rows=1, value=None, disabled=False, description='', reference='', show=True, help_text='', helper_images=None)

Create a text input widget.

Parameters:

Name Type Description Default

key

str

Unique identifier for the widget.

required

label

str

Label for the widget. Defaults to "".

''

max_chars

int

Maximum number of characters allowed. Defaults to 100.

100

max_rows

int

Maximum number of rows allowed. Defaults to 1.

1

value

Optional[str]

Default value. Defaults to None.

None

disabled

bool

Whether the widget is disabled. Defaults to False.

False

description

str

Description of the widget. Defaults to "".

''

reference

str

Reference for the widget. Defaults to "".

''

show

bool

Whether to show the widget in the report. Defaults to True.

True

help_text

str

Help text for the widget. Defaults to ''.

''

helper_images

Optional[List[WidgetHelperImage]]

List of helper images for the widget. Defaults to None.

None

Returns:

Type Description
Optional[str]

Optional[str]: The value of the text input.