##// END OF EJS Templates
added value positional argument to applicable widgets
Jason Goad -
Show More
@@ -26,6 +26,10 b' class _Bool(DOMWidget):'
26 26 description = Unicode('', help="Description of the boolean (label).", sync=True)
27 27 disabled = Bool(False, help="Enable or disable user changes.", sync=True)
28 28
29 def __init__(self, value=None, **kwargs):
30 if value is not None:
31 kwargs['value'] = value
32 super(_Bool, self).__init__(**kwargs)
29 33
30 34 @register('IPython.Checkbox')
31 35 class Checkbox(_Bool):
@@ -25,6 +25,10 b' class _Float(DOMWidget):'
25 25 disabled = Bool(False, help="Enable or disable user changes", sync=True)
26 26 description = Unicode(help="Description of the value this widget represents", sync=True)
27 27
28 def __init__(self, value=None, **kwargs):
29 if value is not None:
30 kwargs['value'] = value
31 super(_Float, self).__init__(**kwargs)
28 32
29 33 class _BoundedFloat(_Float):
30 34 max = CFloat(100.0, help="Max value", sync=True)
@@ -33,7 +37,7 b' class _BoundedFloat(_Float):'
33 37
34 38 def __init__(self, *pargs, **kwargs):
35 39 """Constructor"""
36 DOMWidget.__init__(self, *pargs, **kwargs)
40 super(_BoundedFloat, self).__init__(*pargs, **kwargs)
37 41 self._validate('value', None, self.value)
38 42 self.on_trait_change(self._validate, ['value', 'min', 'max'])
39 43
@@ -40,7 +40,7 b' class _BoundedInt(_Int):'
40 40
41 41 def __init__(self, *pargs, **kwargs):
42 42 """Constructor"""
43 DOMWidget.__init__(self, *pargs, **kwargs)
43 super(_BoundedInt, self).__init__(*pargs, **kwargs)
44 44 self.on_trait_change(self._validate_value, ['value'])
45 45 self.on_trait_change(self._handle_max_changed, ['max'])
46 46 self.on_trait_change(self._handle_min_changed, ['min'])
@@ -108,7 +108,7 b' class _IntRange(_Int):'
108 108 if lower_given != upper_given:
109 109 raise ValueError("Must specify both 'lower' and 'upper' for range widget")
110 110
111 DOMWidget.__init__(self, *pargs, **kwargs)
111 super(_BoundedInt, self).__init__(*pargs, **kwargs)
112 112
113 113 # ensure the traits match, preferring whichever (if any) was given in kwargs
114 114 if value_given:
@@ -27,6 +27,10 b' class _String(DOMWidget):'
27 27 description = Unicode(help="Description of the value this widget represents", sync=True)
28 28 placeholder = Unicode("", help="Placeholder text to display when nothing has been typed", sync=True)
29 29
30 def __init__(self, value=None, **kwargs):
31 if value is not None:
32 kwargs['value'] = value
33 super(_String, self).__init__(**kwargs)
30 34
31 35 @register('IPython.HTML')
32 36 class HTML(_String):
@@ -55,8 +59,8 b' class Text(_String):'
55 59 """Single line textbox widget."""
56 60 _view_name = Unicode('TextView', sync=True)
57 61
58 def __init__(self, **kwargs):
59 super(Text, self).__init__(**kwargs)
62 def __init__(self, *parg, **kwargs):
63 super(Text, self).__init__(*parg, **kwargs)
60 64 self._submission_callbacks = CallbackDispatcher()
61 65 self.on_msg(self._handle_string_msg)
62 66
General Comments 0
You need to be logged in to leave comments. Login now