Project: Implement a SingleOutputWidget
Context
ipywidgests provides an OutputWidget which allows to display values in a widget with all the rich output features of Jupyter. It's used as such:
>>> w = OutputWidget(); w
>>> with w:
... display(value1)
... display(value2)
and the values accumulate. In many use cases however, one is interested in displaying a single value, replacing each time the previous one.
>>> w.clear_output(wait=True)
>>> with w:
... display(value3)
Specifications
Usage:
>>> w = SingleOutputWidget(); w
Display an empty box.
>>> w.value = 35
Display the given value (35), using rich output
>>> w.value = 10
Updates the given value.
This is a natural specialization of the existing OutputWidget in ipywidgests which provides essentially this functionality but is harder to use due to its level generality.
Implementation: wrapping an OutputWidget
Create a new class that inherits from HBox, contains an OutputWidget o as attribute (also contained in the HBox), and has a "value" traitlet/attribute. Upon updating the value, o is cleared with o.clear_output(wait=True)
and print is called on the value.
Dissemination
After discussion with Jason Grout, this would be a welcome addition to ipywidgets. Strategy:
- Implement a proof of concept in a standalone program / notebook
- Clone the development version of ipywidgets and reimplement as a new widget there, with tests, documentation, etc.
- Make a Pull Request to ipywidgets
Bonuses:
- Implementation for xwidgets
- Kernel independent implementation???