msticpy.nbwidgets.query_time module

Module for pre-defined widget layouts.

class msticpy.nbwidgets.query_time.QueryTime(**kwargs)

Bases: RegisteredWidget, IPyDisplayMixin

QueryTime.

Composite widget to capture date and time origin and set start and end times for queries.

See also

RegisteredWidget

Create new instance of QueryTime.

Parameters:
  • origin_time (datetime, optional) – The origin time (the default is datetime.utcnow())

  • description (str, optional) – The description to display (the default is ‘Select time ({units}) to look back’) label is an alias for this parameter

  • before (int, optional) – The default number of units before the origin_time (the default varies based on the unit)

  • after (int, optional) – The default number of units after the origin_time (the default varies based on the unit)

  • start (Union[datetime, str]) – Start of query time - alternative to specifying origin, before, after

  • end (Union[datetime, str]) – End of query time - alternative to specifying origin, before, after

  • timespan (TimeSpan) – TimeSpan of query time - alternative to specifying origin, before, after

  • max_before (int, optional) – The largest value for before (the default varies based on the unit)

  • max_after (int, optional) – The largest value for after (the default varies based on the unit)

  • units (str, optional) – Time unit (the default is ‘hour’) Permissable values are ‘day’, ‘hour’, ‘minute’, ‘second’, ‘week’ These can all be abbreviated down to initial characters (‘d’, ‘m’, etc.)

  • auto_display (bool, optional) – Whether to display on instantiation (the default is False)

ALLOWED_KWARGS = ['id_vals', 'val_attrs', 'nb_params', 'name_space', 'register']
IDS_ATTRIBS = ['before', 'after', '_query_start', '_query_end', '_label']
display()

Display the interactive widgets.

property end

Query end time.

set_time(timespan: TimeSpan | None = None, start: datetime | str | None = None, end: datetime | str | None = None)

Change the time attributes.

Parameters:
  • start (Union[datetime, str]) – Start time - (must specify end)

  • end (Union[datetime, str]) – Start time - (must also specify end)

  • timespan (TimeSpan) – TimeSpan for query time.

property start

Query start time.

property timespan

Return the timespan as a TimeSpan object.

property units

Time units used by control.

property value

Return the timespan as a TimeSpan object.