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