tardis.visualization.widgets.util module

Utility classes and functions for widgets.

class tardis.visualization.widgets.util.PanelTableWidget(data, table_options=None)[source]

Bases: object

Panel-based table widget that mimics qgrid functionality.

Initialize the Panel table widget.

Parameters:
datapandas.DataFrame

Data to display in table widget

table_optionsdict, optional

Table configuration options

change_selection(index_values)[source]

Programmatically change the selection by index values.

property df

Get the current dataframe.

get_selected_rows()[source]

Get the currently selected row indices.

property layout

Get the layout object for compatibility.

on(event_type, callback)[source]

Register an event callback.

show()[source]

Show the table widget using Panel’s show method.

class tardis.visualization.widgets.util.TableSummaryLabel(target_table, table_col_widths, label_key, label_value)[source]

Bases: object

Label like widget to show summary of a Panel table widget.

Also handles aligning the label with the table columns exactly like a summary row.

Initialize a TableSummaryLabel for a table widget.

Parameters:
target_tablePanelTableWidget

Table widget whose summary label it is

table_col_widthslist

A list containing width of each column of table in order (including the index as 1st column). The width values must be proportions of 100 i.e. they must sum to 100

label_keystr

Brief description of what label summarizes about table

label_valueint

Initial summary value of the table to be shown in label

Notes

TableSummaryLabel can only be created for a table with two columns (including index as 1st column) as of now

get_value()[source]

Get the current value displayed in the label.

Returns:
str

The current value as a string

update_and_resize(value)[source]

Update the label value and resize it as per the size of target table.

Resizing is done in such a way so as to match the width of components of label with columns of target table, making it look like another row. This method should be called whenever there is any update in data or layout of target table.

Parameters:
valueint

Value to be shown in label

class tardis.visualization.widgets.util.Timer(timeout, callback)[source]

Bases: object

Timer to implement debouncing using an asynchronous loop.

Notes

This class is reproduced from ipywidgets documentation, for more information please see https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Events.html#debounce

Initialize the Timer with delay time and delayed function.

Parameters:
timeoutfloat
callbackfunction
cancel()[source]
start()[source]
tardis.visualization.widgets.util.create_table_widget(data, table_options=None)[source]

Create table widget object which supports interaction and updating the data.

Parameters:
datapandas.DataFrame

Data you want to display in table widget

table_optionsdict, optional

A dictionary to specify options to use when creating interactive table widget. Supported options: maxVisibleRows.

Returns:
PanelTableWidget

Table widget object

tardis.visualization.widgets.util.debounce(wait)[source]
Decorator that will postpone a function’s execution until after

wait seconds have elapsed since the last time it was invoked.

Parameters:
waitfloat
Returns:
function

Notes

This decorator is reproduced from ipywidgets documentation, for more information please see https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Events.html#debounce