##// END OF EJS Templates
set default value from dict
MinRK -
Show More
@@ -26,7 +26,7 b' from IPython.html.widgets import (Widget, TextWidget,'
26 26 ContainerWidget, DOMWidget)
27 27 from IPython.display import display, clear_output
28 28 from IPython.utils.py3compat import string_types, unicode_type
29 from IPython.utils.traitlets import HasTraits, TraitError, Any, Unicode
29 from IPython.utils.traitlets import HasTraits, Any, Unicode
30 30
31 31 empty = Parameter.empty
32 32
@@ -116,13 +116,13 b' def _widget_from_abbrev(abbrev, default=empty):'
116 116 return abbrev
117 117
118 118 widget = _widget_abbrev(abbrev)
119 if default is not empty and isinstance(abbrev, (list, tuple)):
119 if default is not empty and isinstance(abbrev, (list, tuple, dict)):
120 120 # if it's not a single-value abbreviation,
121 121 # set the initial value from the default
122 122 try:
123 123 widget.value = default
124 except TraitError:
125 # warn?
124 except Exception:
125 # ignore failure to set default
126 126 pass
127 127 if widget is None:
128 128 raise ValueError("%r cannot be transformed to a Widget" % (abbrev,))
General Comments 0
You need to be logged in to leave comments. Login now