msticpy.nbwidgets.query_time module

Module for pre-defined widget layouts.

class msticpy.nbwidgets.query_time.QueryTime(*, description: str | None = None, label: str | None = None, before: int | None = None, after: int | None = None, units: str | None = None, origin_time: datetime | None = None, max_before: int | None = None, max_after: int | None = None, timespan: TimeSpan | None = None, start: datetime | None = None, end: datetime | None = None, auto_display: bool = False, **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

  • label (str, optional) – The description to display (the default is ‘Select time ({units}) to look back’) description 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 ‘min’) 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: ClassVar[List[str]] = ['id_vals', 'val_attrs', 'nb_params', 'name_space', 'register']
IDS_ATTRIBS: ClassVar[list[str]] = ['before', 'after', '_query_start', '_query_end', '_label']
display()

Display the interactive widgets.

property end: datetime | None

Query end time.

set_time(timespan: TimeSpan | None = None, start: datetime | str | None = None, end: datetime | str | None = 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: datetime | None

Query start time.

property timespan: TimeSpan

Return the timespan as a TimeSpan object.

property units: str

Time units used by control.

property value: TimeSpan

Return the timespan as a TimeSpan object.