valuewidget.py 834 B

123456789101112131415161718192021222324252627
  1. # Copyright (c) Jupyter Development Team.
  2. # Distributed under the terms of the Modified BSD License.
  3. """Contains the ValueWidget class"""
  4. from .widget import Widget
  5. from traitlets import Any
  6. class ValueWidget(Widget):
  7. """Widget that can be used for the input of an interactive function"""
  8. value = Any(help="The value of the widget.")
  9. def get_interact_value(self):
  10. """Return the value for this widget which should be passed to
  11. interactive functions. Custom widgets can change this method
  12. to process the raw value ``self.value``.
  13. """
  14. return self.value
  15. def _repr_keys(self):
  16. # Ensure value key comes first, and is always present
  17. yield 'value'
  18. for key in super(ValueWidget, self)._repr_keys():
  19. if key != 'value':
  20. yield key