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