Show More
@@ -320,6 +320,11 b' define([' | |||||
320 | .css('width', '50%') |
|
320 | .css('width', '50%') | |
321 | .appendTo(this.$progress); |
|
321 | .appendTo(this.$progress); | |
322 | this.update(); // Set defaults. |
|
322 | this.update(); // Set defaults. | |
|
323 | ||||
|
324 | this.model.on('change:bar_style', function(model, value) { | |||
|
325 | this.update_bar_style(); | |||
|
326 | }, this); | |||
|
327 | this.update_bar_style(''); | |||
323 | }, |
|
328 | }, | |
324 |
|
329 | |||
325 | update : function(){ |
|
330 | update : function(){ | |
@@ -344,6 +349,16 b' define([' | |||||
344 | return ProgressView.__super__.update.apply(this); |
|
349 | return ProgressView.__super__.update.apply(this); | |
345 | }, |
|
350 | }, | |
346 |
|
351 | |||
|
352 | update_bar_style: function(previous_trait_value) { | |||
|
353 | var class_map = { | |||
|
354 | success: ['progress-bar-success'], | |||
|
355 | info: ['progress-bar-info'], | |||
|
356 | warning: ['progress-bar-warning'], | |||
|
357 | danger: ['progress-bar-danger'] | |||
|
358 | }; | |||
|
359 | this.update_mapped_classes(class_map, 'bar_style', previous_trait_value, this.$bar); | |||
|
360 | }, | |||
|
361 | ||||
347 | update_attr: function(name, value) { |
|
362 | update_attr: function(name, value) { | |
348 | // Set a css attr of the widget view. |
|
363 | // Set a css attr of the widget view. | |
349 | if (name.substring(0, 6) == 'border' || name == 'width' || |
|
364 | if (name.substring(0, 6) == 'border' || name == 'width' || |
@@ -14,7 +14,7 b' Represents a boolean using a widget.' | |||||
14 | # Imports |
|
14 | # Imports | |
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
16 | from .widget import DOMWidget |
|
16 | from .widget import DOMWidget | |
17 | from IPython.utils.traitlets import Unicode, Bool |
|
17 | from IPython.utils.traitlets import Unicode, Bool, CaselessStrEnum | |
18 | from IPython.utils.warn import DeprecatedClass |
|
18 | from IPython.utils.warn import DeprecatedClass | |
19 |
|
19 | |||
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- |
@@ -15,7 +15,7 b' click events on the button and trigger backend code when the clicks are fired.' | |||||
15 | # Imports |
|
15 | # Imports | |
16 | #----------------------------------------------------------------------------- |
|
16 | #----------------------------------------------------------------------------- | |
17 | from .widget import DOMWidget, CallbackDispatcher |
|
17 | from .widget import DOMWidget, CallbackDispatcher | |
18 | from IPython.utils.traitlets import Unicode, Bool |
|
18 | from IPython.utils.traitlets import Unicode, Bool, CaselessStrEnum | |
19 | from IPython.utils.warn import DeprecatedClass |
|
19 | from IPython.utils.warn import DeprecatedClass | |
20 |
|
20 | |||
21 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- |
@@ -14,7 +14,7 b' Represents an unbounded float using a widget.' | |||||
14 | # Imports |
|
14 | # Imports | |
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
16 | from .widget import DOMWidget |
|
16 | from .widget import DOMWidget | |
17 | from IPython.utils.traitlets import Unicode, CFloat, Bool, Enum, Tuple |
|
17 | from IPython.utils.traitlets import Unicode, CFloat, Bool, CaselessStrEnum, Tuple | |
18 | from IPython.utils.warn import DeprecatedClass |
|
18 | from IPython.utils.warn import DeprecatedClass | |
19 |
|
19 | |||
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
@@ -53,8 +53,9 b' class BoundedFloatText(_BoundedFloat):' | |||||
53 |
|
53 | |||
54 | class FloatSlider(_BoundedFloat): |
|
54 | class FloatSlider(_BoundedFloat): | |
55 | _view_name = Unicode('FloatSliderView', sync=True) |
|
55 | _view_name = Unicode('FloatSliderView', sync=True) | |
56 |
orientation = Enum([ |
|
56 | orientation = CaselessStrEnum(values=['horizontal', 'vertical'], | |
57 | help="Vertical or horizontal.", sync=True) |
|
57 | default_value='horizontal', | |
|
58 | help="Vertical or horizontal.", allow_none=False, sync=True) | |||
58 | _range = Bool(False, help="Display a range selector", sync=True) |
|
59 | _range = Bool(False, help="Display a range selector", sync=True) | |
59 | readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) |
|
60 | readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) | |
60 | slider_color = Unicode(sync=True) |
|
61 | slider_color = Unicode(sync=True) | |
@@ -63,6 +64,11 b' class FloatSlider(_BoundedFloat):' | |||||
63 | class FloatProgress(_BoundedFloat): |
|
64 | class FloatProgress(_BoundedFloat): | |
64 | _view_name = Unicode('ProgressView', sync=True) |
|
65 | _view_name = Unicode('ProgressView', sync=True) | |
65 |
|
66 | |||
|
67 | bar_style = CaselessStrEnum( | |||
|
68 | values=['success', 'info', 'warning', 'danger', ''], | |||
|
69 | default_value='', allow_none=True, sync=True, help="""Use a | |||
|
70 | predefined styling for the progess bar.""") | |||
|
71 | ||||
66 | class _FloatRange(_Float): |
|
72 | class _FloatRange(_Float): | |
67 | value = Tuple(CFloat, CFloat, default_value=(0.0, 1.0), help="Tuple of (lower, upper) bounds", sync=True) |
|
73 | value = Tuple(CFloat, CFloat, default_value=(0.0, 1.0), help="Tuple of (lower, upper) bounds", sync=True) | |
68 | lower = CFloat(0.0, help="Lower bound", sync=False) |
|
74 | lower = CFloat(0.0, help="Lower bound", sync=False) |
@@ -14,7 +14,7 b' Represents an unbounded int using a widget.' | |||||
14 | # Imports |
|
14 | # Imports | |
15 | #----------------------------------------------------------------------------- |
|
15 | #----------------------------------------------------------------------------- | |
16 | from .widget import DOMWidget |
|
16 | from .widget import DOMWidget | |
17 | from IPython.utils.traitlets import Unicode, CInt, Bool, Enum, Tuple |
|
17 | from IPython.utils.traitlets import Unicode, CInt, Bool, CaselessStrEnum, Tuple | |
18 | from IPython.utils.warn import DeprecatedClass |
|
18 | from IPython.utils.warn import DeprecatedClass | |
19 |
|
19 | |||
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
@@ -58,7 +58,8 b' class BoundedIntText(_BoundedInt):' | |||||
58 | class IntSlider(_BoundedInt): |
|
58 | class IntSlider(_BoundedInt): | |
59 | """Slider widget that represents a int bounded by a minimum and maximum value.""" |
|
59 | """Slider widget that represents a int bounded by a minimum and maximum value.""" | |
60 | _view_name = Unicode('IntSliderView', sync=True) |
|
60 | _view_name = Unicode('IntSliderView', sync=True) | |
61 |
orientation = Enum([ |
|
61 | orientation = CaselessStrEnum(values=['horizontal', 'vertical'], | |
|
62 | default_value='horizontal', allow_none=False, | |||
62 | help="Vertical or horizontal.", sync=True) |
|
63 | help="Vertical or horizontal.", sync=True) | |
63 | _range = Bool(False, help="Display a range selector", sync=True) |
|
64 | _range = Bool(False, help="Display a range selector", sync=True) | |
64 | readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) |
|
65 | readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) | |
@@ -69,6 +70,11 b' class IntProgress(_BoundedInt):' | |||||
69 | """Progress bar that represents a int bounded by a minimum and maximum value.""" |
|
70 | """Progress bar that represents a int bounded by a minimum and maximum value.""" | |
70 | _view_name = Unicode('ProgressView', sync=True) |
|
71 | _view_name = Unicode('ProgressView', sync=True) | |
71 |
|
72 | |||
|
73 | bar_style = CaselessStrEnum( | |||
|
74 | values=['success', 'info', 'warning', 'danger', ''], | |||
|
75 | default_value='', allow_none=True, sync=True, help="""Use a | |||
|
76 | predefined styling for the progess bar.""") | |||
|
77 | ||||
72 | class _IntRange(_Int): |
|
78 | class _IntRange(_Int): | |
73 | value = Tuple(CInt, CInt, default_value=(0, 1), help="Tuple of (lower, upper) bounds", sync=True) |
|
79 | value = Tuple(CInt, CInt, default_value=(0, 1), help="Tuple of (lower, upper) bounds", sync=True) | |
74 | lower = CInt(0, help="Lower bound", sync=False) |
|
80 | lower = CInt(0, help="Lower bound", sync=False) |
@@ -18,7 +18,7 b' from collections import OrderedDict' | |||||
18 | from threading import Lock |
|
18 | from threading import Lock | |
19 |
|
19 | |||
20 | from .widget import DOMWidget |
|
20 | from .widget import DOMWidget | |
21 | from IPython.utils.traitlets import Unicode, List, Bool, Any, Dict, TraitError |
|
21 | from IPython.utils.traitlets import Unicode, List, Bool, Any, Dict, TraitError, CaselessStrEnum | |
22 | from IPython.utils.py3compat import unicode_type |
|
22 | from IPython.utils.py3compat import unicode_type | |
23 | from IPython.utils.warn import DeprecatedClass |
|
23 | from IPython.utils.warn import DeprecatedClass | |
24 |
|
24 | |||
@@ -125,6 +125,11 b' class Dropdown(_Selection):' | |||||
125 | """Allows you to select a single item from a dropdown.""" |
|
125 | """Allows you to select a single item from a dropdown.""" | |
126 | _view_name = Unicode('DropdownView', sync=True) |
|
126 | _view_name = Unicode('DropdownView', sync=True) | |
127 |
|
127 | |||
|
128 | button_style = CaselessStrEnum( | |||
|
129 | values=['primary', 'success', 'info', 'warning', 'danger', ''], | |||
|
130 | default_value='', allow_none=True, sync=True, help="""Use a | |||
|
131 | predefined styling for the buttons.""") | |||
|
132 | ||||
128 |
|
133 | |||
129 | class RadioButtons(_Selection): |
|
134 | class RadioButtons(_Selection): | |
130 | """Group of radio buttons that represent an enumeration. Only one radio |
|
135 | """Group of radio buttons that represent an enumeration. Only one radio |
General Comments 0
You need to be logged in to leave comments.
Login now