Show More
@@ -1,12 +1,12 b'' | |||
|
1 |
from |
|
|
1 | from widget import Widget | |
|
2 | 2 | from IPython.utils.traitlets import Unicode, Bool, List |
|
3 | 3 | |
|
4 | 4 | class BoolWidget(Widget): |
|
5 | 5 | target_name = Unicode('BoolWidgetModel') |
|
6 | 6 | default_view_name = Unicode('CheckboxView') |
|
7 | 7 | _keys = ['value', 'description', 'disabled'] |
|
8 | 8 | |
|
9 | 9 | value = Bool(False) |
|
10 | 10 | description = Unicode('') # Description of the boolean (label). |
|
11 | 11 | disabled = Bool(False) # Enable or disable user changes |
|
12 | 12 | No newline at end of file |
@@ -1,45 +1,45 b'' | |||
|
1 | 1 | import inspect |
|
2 | 2 | import types |
|
3 | 3 | |
|
4 |
from |
|
|
4 | from widget import Widget | |
|
5 | 5 | from IPython.utils.traitlets import Unicode, Bool, Int |
|
6 | 6 | |
|
7 | 7 | class ButtonWidget(Widget): |
|
8 | 8 | target_name = Unicode('ButtonWidgetModel') |
|
9 | 9 | default_view_name = Unicode('ButtonView') |
|
10 | 10 | _keys = ['clicks', 'description', 'disabled'] |
|
11 | 11 | |
|
12 | 12 | clicks = Int(0) |
|
13 | 13 | description = Unicode('') # Description of the button (label). |
|
14 | 14 | disabled = Bool(False) # Enable or disable user changes |
|
15 | 15 | |
|
16 | 16 | _click_handlers = [] |
|
17 | 17 | |
|
18 | 18 | |
|
19 | 19 | def on_click(self, callback, remove=False): |
|
20 | 20 | if remove: |
|
21 | 21 | self._click_handlers.remove(callback) |
|
22 | 22 | else: |
|
23 | 23 | self._click_handlers.append(callback) |
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 | def _clicks_changed(self, name, old, new): |
|
27 | 27 | if new > old: |
|
28 | 28 | for handler in self._click_handlers: |
|
29 | 29 | if callable(handler): |
|
30 | 30 | argspec = inspect.getargspec(handler) |
|
31 | 31 | nargs = len(argspec[0]) |
|
32 | 32 | |
|
33 | 33 | # Bound methods have an additional 'self' argument |
|
34 | 34 | if isinstance(handler, types.MethodType): |
|
35 | 35 | nargs -= 1 |
|
36 | 36 | |
|
37 | 37 | # Call the callback |
|
38 | 38 | if nargs == 0: |
|
39 | 39 | handler() |
|
40 | 40 | elif nargs == 1: |
|
41 | 41 | handler(self) |
|
42 | 42 | else: |
|
43 | 43 | raise TypeError('ButtonWidget click callback must ' \ |
|
44 | 44 | 'accept 0 or 1 arguments.') |
|
45 | 45 |
@@ -1,42 +1,42 b'' | |||
|
1 |
from |
|
|
1 | from widget import Widget | |
|
2 | 2 | from IPython.utils.traitlets import Unicode, Bool |
|
3 | 3 | |
|
4 | 4 | class ContainerWidget(Widget): |
|
5 | 5 | target_name = Unicode('container_widget') |
|
6 | 6 | default_view_name = Unicode('ContainerView') |
|
7 | 7 | _keys = ['_vbox', '_hbox', '_start', '_end', '_center'] |
|
8 | 8 | _trait_changing = False |
|
9 | 9 | |
|
10 | 10 | _hbox = Bool(False) |
|
11 | 11 | _vbox = Bool(False) |
|
12 | 12 | _start = Bool(False) |
|
13 | 13 | _end = Bool(False) |
|
14 | 14 | _center = Bool(False) |
|
15 | 15 | |
|
16 | 16 | def hbox(self, enabled=True): |
|
17 | 17 | self._hbox = enabled |
|
18 | 18 | if enabled: |
|
19 | 19 | self._vbox = False |
|
20 | 20 | |
|
21 | 21 | def vbox(self, enabled=True): |
|
22 | 22 | self._vbox = enabled |
|
23 | 23 | if enabled: |
|
24 | 24 | self._hbox = False |
|
25 | 25 | |
|
26 | 26 | def start(self, enabled=True): |
|
27 | 27 | self._start = enabled |
|
28 | 28 | if enabled: |
|
29 | 29 | self._end = False |
|
30 | 30 | self._center = False |
|
31 | 31 | |
|
32 | 32 | def end(self, enabled=True): |
|
33 | 33 | self._end = enabled |
|
34 | 34 | if enabled: |
|
35 | 35 | self._start = False |
|
36 | 36 | self._center = False |
|
37 | 37 | |
|
38 | 38 | def center(self, enabled=True): |
|
39 | 39 | self._center = enabled |
|
40 | 40 | if enabled: |
|
41 | 41 | self._start = False |
|
42 | 42 | self._end = False |
@@ -1,10 +1,10 b'' | |||
|
1 |
from |
|
|
1 | from widget import Widget | |
|
2 | 2 | from IPython.utils.traitlets import Unicode, Float, Bool, List |
|
3 | 3 | |
|
4 | 4 | class FloatWidget(Widget): |
|
5 | 5 | target_name = Unicode('FloatWidgetModel') |
|
6 | 6 | default_view_name = Unicode('FloatTextView') |
|
7 | 7 | _keys = ['value', 'disabled'] |
|
8 | 8 | |
|
9 | 9 | value = Float(0.0) |
|
10 | 10 | disabled = Bool(False) # Enable or disable user changes |
@@ -1,14 +1,14 b'' | |||
|
1 |
from |
|
|
1 | from widget import Widget | |
|
2 | 2 | from IPython.utils.traitlets import Unicode, Float, Bool, List |
|
3 | 3 | |
|
4 | 4 | class FloatRangeWidget(Widget): |
|
5 | 5 | target_name = Unicode('FloatRangeWidgetModel') |
|
6 | 6 | default_view_name = Unicode('FloatSliderView') |
|
7 | 7 | _keys = ['value', 'step', 'max', 'min', 'disabled', 'orientation'] |
|
8 | 8 | |
|
9 | 9 | value = Float(0.0) |
|
10 | 10 | max = Float(100.0) # Max value |
|
11 | 11 | min = Float(0.0) # Min value |
|
12 | 12 | disabled = Bool(False) # Enable or disable user changes |
|
13 | 13 | step = Float(0.1) # Minimum step that the value can take (ignored by some views) |
|
14 | 14 | orientation = Unicode(u'horizontal') # Vertical or horizontal (ignored by some views) |
@@ -1,10 +1,10 b'' | |||
|
1 |
from |
|
|
1 | from widget import Widget | |
|
2 | 2 | from IPython.utils.traitlets import Unicode, Int, Bool, List |
|
3 | 3 | |
|
4 | 4 | class IntWidget(Widget): |
|
5 | 5 | target_name = Unicode('IntWidgetModel') |
|
6 | 6 | default_view_name = Unicode('IntTextView') |
|
7 | 7 | _keys = ['value', 'disabled'] |
|
8 | 8 | |
|
9 | 9 | value = Int(0) |
|
10 | 10 | disabled = Bool(False) # Enable or disable user changes |
@@ -1,14 +1,14 b'' | |||
|
1 |
from |
|
|
1 | from widget import Widget | |
|
2 | 2 | from IPython.utils.traitlets import Unicode, Int, Bool, List |
|
3 | 3 | |
|
4 | 4 | class IntRangeWidget(Widget): |
|
5 | 5 | target_name = Unicode('IntRangeWidgetModel') |
|
6 | 6 | default_view_name = Unicode('IntSliderView') |
|
7 | 7 | _keys = ['value', 'step', 'max', 'min', 'disabled', 'orientation'] |
|
8 | 8 | |
|
9 | 9 | value = Int(0) |
|
10 | 10 | max = Int(100) # Max value |
|
11 | 11 | min = Int(0) # Min value |
|
12 | 12 | disabled = Bool(False) # Enable or disable user changes |
|
13 | 13 | step = Int(1) # Minimum step that the value can take (ignored by some views) |
|
14 | 14 | orientation = Unicode(u'horizontal') # Vertical or horizontal (ignored by some views) |
@@ -1,12 +1,12 b'' | |||
|
1 |
from |
|
|
1 | from widget import Widget | |
|
2 | 2 | from IPython.utils.traitlets import Unicode, List, Bool |
|
3 | 3 | |
|
4 | 4 | class SelectionWidget(Widget): |
|
5 | 5 | target_name = Unicode('SelectionWidgetModel') |
|
6 | 6 | default_view_name = Unicode('DropdownView') |
|
7 | 7 | _keys = ['value', 'values', 'disabled'] |
|
8 | 8 | |
|
9 | 9 | value = Unicode() |
|
10 | 10 | values = List() # List of values the user can select |
|
11 | 11 | disabled = Bool(False) # Enable or disable user changes |
|
12 | 12 | No newline at end of file |
@@ -1,11 +1,11 b'' | |||
|
1 |
from |
|
|
1 | from widget import Widget | |
|
2 | 2 | from IPython.utils.traitlets import Unicode, Bool, List |
|
3 | 3 | |
|
4 | 4 | class StringWidget(Widget): |
|
5 | 5 | target_name = Unicode('StringWidgetModel') |
|
6 | 6 | default_view_name = Unicode('TextboxView') |
|
7 | 7 | _keys = ['value', 'disabled'] |
|
8 | 8 | |
|
9 | 9 | value = Unicode() |
|
10 | 10 | disabled = Bool(False) # Enable or disable user changes |
|
11 | 11 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now