gtrace.draw.viewer.widget
Jupyter widget front end for the gtrace viewer (Stage 2).
LayoutViewer wraps the same dependency-free viewer core that the static HTML output uses, so a notebook gets zoom, pan and click readout without leaving the cell. The scene travels over the widget’s traitlets, which means a re-trace can be pushed into a live view:
w = layout.widget() w # displays the viewer M1.HRcenter = [0.6, 0] w.update() # re-traces and redraws in place
anywidget is an optional dependency: importing gtrace does not require it, and the HTML output keeps working without it.
Attributes
Exceptions
Raised when the notebook viewer is asked for but anywidget is |
Functions
Whether the notebook viewer can be used, i.e. whether anywidget is |
|
Return the source of the anywidget ESM wrapper as a string. |
|
Return the ESM module served to the notebook front end. |
|
Define the widget class on first use, so that importing this module |
|
|
Construct the notebook viewer widget. |
Module Contents
- gtrace.draw.viewer.widget.__author__ = 'Yoichi Aso'
- gtrace.draw.viewer.widget.__copyright__ = 'Copyright 2011-2026, Yoichi Aso'
- gtrace.draw.viewer.widget.__credits__ = ['Yoichi Aso']
- gtrace.draw.viewer.widget.__license__ = 'BSD'
- gtrace.draw.viewer.widget.__version__ = '0.8.0'
- gtrace.draw.viewer.widget.__maintainer__ = 'Yoichi Aso'
- gtrace.draw.viewer.widget.__email__ = 'asoy01@gmail.com'
- gtrace.draw.viewer.widget.__status__ = 'Beta'
- exception gtrace.draw.viewer.widget.WidgetNotAvailable
Bases:
ImportErrorRaised when the notebook viewer is asked for but anywidget is not installed.
- gtrace.draw.viewer.widget.widget_available()
Whether the notebook viewer can be used, i.e. whether anywidget is importable.
- gtrace.draw.viewer.widget._require_anywidget()
- gtrace.draw.viewer.widget.widget_js()
Return the source of the anywidget ESM wrapper as a string.
- gtrace.draw.viewer.widget.widget_esm()
Return the ESM module served to the notebook front end.
It is the viewer core followed by the anywidget wrapper. The core is an IIFE that publishes GTraceViewer on globalThis, so concatenating the two is enough to bring it into scope; there is no build step and no module resolution to go wrong, which was the lesson of the dxf-viewer experiment.
- gtrace.draw.viewer.widget._LAYOUT_VIEWER = None
- gtrace.draw.viewer.widget._build_class()
Define the widget class on first use, so that importing this module does not require anywidget.
- gtrace.draw.viewer.widget.LayoutViewer(*args, **kwargs)
Construct the notebook viewer widget.
This is a function rather than the class itself so that anywidget is imported only when a widget is actually created.