msticpy.nbwidgets.core module

Module for pre-defined widget layouts.

class msticpy.nbwidgets.core.IPyDisplayMixin

Bases: object

IPython display mixin class.


Display the interactive widgets.

class msticpy.nbwidgets.core.RegisteredWidget(id_vals: ~typing.Optional[~typing.List[~typing.Any]] = None, val_attrs: ~typing.Optional[~typing.List[str]] = None, nb_params: ~typing.Optional[~typing.Dict[str, str]] = None, name_space: ~typing.Dict[str, ~typing.Any] = {'ABC': <class 'abc.ABC'>, 'Any': typing.Any, 'Dict': typing.Dict, 'IPyDisplayMixin': <class 'msticpy.nbwidgets.core.IPyDisplayMixin'>, 'IntEnum': <enum 'IntEnum'>, 'List': typing.List, 'Optional': typing.Optional, 'RegisteredWidget': <class 'msticpy.nbwidgets.core.RegisteredWidget'>, 'TimeUnit': <enum 'TimeUnit'>, 'VERSION': '2.3.0', 'WeakValueDictionary': <class 'weakref.WeakValueDictionary'>, '_WIDGET_REG': <WeakValueDictionary>, '__annotations__': {'_WIDGET_REG': <class 'weakref.WeakValueDictionary'>}, '__author__': 'Ian Hellen', '__builtins__': {'ArithmeticError': <class 'ArithmeticError'>, 'AssertionError': <class 'AssertionError'>, 'AttributeError': <class 'AttributeError'>, 'BaseException': <class 'BaseException'>, 'BlockingIOError': <class 'BlockingIOError'>, 'BrokenPipeError': <class 'BrokenPipeError'>, 'BufferError': <class 'BufferError'>, 'BytesWarning': <class 'BytesWarning'>, 'ChildProcessError': <class 'ChildProcessError'>, 'ConnectionAbortedError': <class 'ConnectionAbortedError'>, 'ConnectionError': <class 'ConnectionError'>, 'ConnectionRefusedError': <class 'ConnectionRefusedError'>, 'ConnectionResetError': <class 'ConnectionResetError'>, 'DeprecationWarning': <class 'DeprecationWarning'>, 'EOFError': <class 'EOFError'>, 'Ellipsis': Ellipsis, 'EnvironmentError': <class 'OSError'>, 'Exception': <class 'Exception'>, 'False': False, 'FileExistsError': <class 'FileExistsError'>, 'FileNotFoundError': <class 'FileNotFoundError'>, 'FloatingPointError': <class 'FloatingPointError'>, 'FutureWarning': <class 'FutureWarning'>, 'GeneratorExit': <class 'GeneratorExit'>, 'IOError': <class 'OSError'>, 'ImportError': <class 'ImportError'>, 'ImportWarning': <class 'ImportWarning'>, 'IndentationError': <class 'IndentationError'>, 'IndexError': <class 'IndexError'>, 'InterruptedError': <class 'InterruptedError'>, 'IsADirectoryError': <class 'IsADirectoryError'>, 'KeyError': <class 'KeyError'>, 'KeyboardInterrupt': <class 'KeyboardInterrupt'>, 'LookupError': <class 'LookupError'>, 'MemoryError': <class 'MemoryError'>, 'ModuleNotFoundError': <class 'ModuleNotFoundError'>, 'NameError': <class 'NameError'>, 'None': None, 'NotADirectoryError': <class 'NotADirectoryError'>, 'NotImplemented': NotImplemented, 'NotImplementedError': <class 'NotImplementedError'>, 'OSError': <class 'OSError'>, 'OverflowError': <class 'OverflowError'>, 'PendingDeprecationWarning': <class 'PendingDeprecationWarning'>, 'PermissionError': <class 'PermissionError'>, 'ProcessLookupError': <class 'ProcessLookupError'>, 'RecursionError': <class 'RecursionError'>, 'ReferenceError': <class 'ReferenceError'>, 'ResourceWarning': <class 'ResourceWarning'>, 'RuntimeError': <class 'RuntimeError'>, 'RuntimeWarning': <class 'RuntimeWarning'>, 'StopAsyncIteration': <class 'StopAsyncIteration'>, 'StopIteration': <class 'StopIteration'>, 'SyntaxError': <class 'SyntaxError'>, 'SyntaxWarning': <class 'SyntaxWarning'>, 'SystemError': <class 'SystemError'>, 'SystemExit': <class 'SystemExit'>, 'TabError': <class 'TabError'>, 'TimeoutError': <class 'TimeoutError'>, 'True': True, 'TypeError': <class 'TypeError'>, 'UnboundLocalError': <class 'UnboundLocalError'>, 'UnicodeDecodeError': <class 'UnicodeDecodeError'>, 'UnicodeEncodeError': <class 'UnicodeEncodeError'>, 'UnicodeError': <class 'UnicodeError'>, 'UnicodeTranslateError': <class 'UnicodeTranslateError'>, 'UnicodeWarning': <class 'UnicodeWarning'>, 'UserWarning': <class 'UserWarning'>, 'ValueError': <class 'ValueError'>, 'Warning': <class 'Warning'>, 'ZeroDivisionError': <class 'ZeroDivisionError'>, '__build_class__': <built-in function __build_class__>, '__debug__': True, '__doc__': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.", '__import__': <built-in function __import__>, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__name__': 'builtins', '__package__': '', '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>, origin='built-in'), 'abs': <built-in function abs>, 'all': <built-in function all>, 'any': <built-in function any>, 'ascii': <built-in function ascii>, 'bin': <built-in function bin>, 'bool': <class 'bool'>, 'breakpoint': <built-in function breakpoint>, 'bytearray': <class 'bytearray'>, 'bytes': <class 'bytes'>, 'callable': <built-in function callable>, 'chr': <built-in function chr>, 'classmethod': <class 'classmethod'>, 'compile': <built-in function compile>, 'complex': <class 'complex'>, 'copyright': Copyright (c) 2001-2022 Python Software Foundation. All Rights Reserved.  Copyright (c) 2000 All Rights Reserved.  Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved.  Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved., 'credits':     Thanks to CWI, CNRI,, Zope Corporation and a cast of thousands     for supporting Python development.  See for more information., 'delattr': <built-in function delattr>, 'dict': <class 'dict'>, 'dir': <built-in function dir>, 'divmod': <built-in function divmod>, 'enumerate': <class 'enumerate'>, 'eval': <built-in function eval>, 'exec': <built-in function exec>, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'filter': <class 'filter'>, 'float': <class 'float'>, 'format': <built-in function format>, 'frozenset': <class 'frozenset'>, 'getattr': <built-in function getattr>, 'globals': <built-in function globals>, 'hasattr': <built-in function hasattr>, 'hash': <built-in function hash>, 'help': Type help() for interactive help, or help(object) for help about object., 'hex': <built-in function hex>, 'id': <built-in function id>, 'input': <built-in function input>, 'int': <class 'int'>, 'isinstance': <built-in function isinstance>, 'issubclass': <built-in function issubclass>, 'iter': <built-in function iter>, 'len': <built-in function len>, 'license': Type license() to see the full license text, 'list': <class 'list'>, 'locals': <built-in function locals>, 'map': <class 'map'>, 'max': <built-in function max>, 'memoryview': <class 'memoryview'>, 'min': <built-in function min>, 'next': <built-in function next>, 'object': <class 'object'>, 'oct': <built-in function oct>, 'open': <built-in function open>, 'ord': <built-in function ord>, 'pow': <built-in function pow>, 'print': <built-in function print>, 'property': <class 'property'>, 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'range': <class 'range'>, 'repr': <built-in function repr>, 'reversed': <class 'reversed'>, 'round': <built-in function round>, 'set': <class 'set'>, 'setattr': <built-in function setattr>, 'slice': <class 'slice'>, 'sorted': <built-in function sorted>, 'staticmethod': <class 'staticmethod'>, 'str': <class 'str'>, 'sum': <built-in function sum>, 'super': <class 'super'>, 'tuple': <class 'tuple'>, 'type': <class 'type'>, 'vars': <built-in function vars>, 'zip': <class 'zip'>}, '__cached__': '/home/docs/checkouts/', '__doc__': 'Module for pre-defined widget layouts.', '__file__': '/home/docs/checkouts/', '__loader__': <_frozen_importlib_external.SourceFileLoader object>, '__name__': 'msticpy.nbwidgets.core', '__package__': 'msticpy.nbwidgets', '__spec__': ModuleSpec(name='msticpy.nbwidgets.core', loader=<_frozen_importlib_external.SourceFileLoader object>, origin='/home/docs/checkouts/'), '__version__': '2.3.0', 'default_before_after': <function default_before_after>, 'default_max_buffer': <function default_max_buffer>, 'display': IPython.display.display, 'parse_time_unit': <function parse_time_unit>}, register: bool = True, **kwargs)

Bases: ABC

Register widget in the widget registry.

Registered widgets will store their values in the register. Each widget has an ID that that is derived from one or more of the initialization parameters. If an instance of the same widget class is created with the same parameters, its previous value will be repopulated from the registry. This is especially useful in notebooks where people accidentally re-run the same cell after entering values.

Initialize a registered widget.

  • id_vals (Optional[List[Any]], optional) – The list of parameter values to use to identify this widget instance, by default None

  • val_attrs (Optional[List[str]], optional) – The names of the attributes to persist in the registry and recall, by default [“value”]

  • nb_params (Optional[Dict[str, str]], optional) – A dictionary of attribute names and global variables. If the variable exists in the global namespace it will be used to populate the corresponding widget attribute. This is only done if the widget attribute currently has no value (i.e. restoring a value from the registry takes priority over this), by default None

  • name_space (Dict[str, Any], optional) – Namespace to look for global variables, by default None

  • register (bool) – Do not register the widget or retrieve values from previously- registered instance.

ALLOWED_KWARGS = ['id_vals', 'val_attrs', 'nb_params', 'name_space', 'register']
class msticpy.nbwidgets.core.TimeUnit(value)

Bases: IntEnum

Time unit enumeration and value.

DAY = 86400
HOUR = 3600
WEEK = 604800
msticpy.nbwidgets.core.default_before_after(default: Optional[int], unit: TimeUnit) int

Return default before and after bounds for a TimeUnit.

msticpy.nbwidgets.core.default_max_buffer(max_default: Optional[int], default: int, unit: TimeUnit) int

Return the max time buffer for a give time unit.

msticpy.nbwidgets.core.parse_time_unit(unit_str: str) TimeUnit

Return the TimeUnit enum matching the input string.