Show More
@@ -320,6 +320,11 b' define([' | |||
|
320 | 320 | .css('width', '50%') |
|
321 | 321 | .appendTo(this.$progress); |
|
322 | 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 | 330 | update : function(){ |
@@ -344,6 +349,16 b' define([' | |||
|
344 | 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 | 362 | update_attr: function(name, value) { |
|
348 | 363 | // Set a css attr of the widget view. |
|
349 | 364 | if (name.substring(0, 6) == 'border' || name == 'width' || |
@@ -14,7 +14,7 b' Represents a boolean using a widget.' | |||
|
14 | 14 | # Imports |
|
15 | 15 | #----------------------------------------------------------------------------- |
|
16 | 16 | from .widget import DOMWidget |
|
17 | from IPython.utils.traitlets import Unicode, Bool | |
|
17 | from IPython.utils.traitlets import Unicode, Bool, CaselessStrEnum | |
|
18 | 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 | 15 | # Imports |
|
16 | 16 | #----------------------------------------------------------------------------- |
|
17 | 17 | from .widget import DOMWidget, CallbackDispatcher |
|
18 | from IPython.utils.traitlets import Unicode, Bool | |
|
18 | from IPython.utils.traitlets import Unicode, Bool, CaselessStrEnum | |
|
19 | 19 | from IPython.utils.warn import DeprecatedClass |
|
20 | 20 | |
|
21 | 21 | #----------------------------------------------------------------------------- |
@@ -14,7 +14,7 b' Represents an unbounded float using a widget.' | |||
|
14 | 14 | # Imports |
|
15 | 15 | #----------------------------------------------------------------------------- |
|
16 | 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 | 18 | from IPython.utils.warn import DeprecatedClass |
|
19 | 19 | |
|
20 | 20 | #----------------------------------------------------------------------------- |
@@ -53,8 +53,9 b' class BoundedFloatText(_BoundedFloat):' | |||
|
53 | 53 | |
|
54 | 54 | class FloatSlider(_BoundedFloat): |
|
55 | 55 | _view_name = Unicode('FloatSliderView', sync=True) |
|
56 |
orientation = Enum([ |
|
|
57 | help="Vertical or horizontal.", sync=True) | |
|
56 | orientation = CaselessStrEnum(values=['horizontal', 'vertical'], | |
|
57 | default_value='horizontal', | |
|
58 | help="Vertical or horizontal.", allow_none=False, sync=True) | |
|
58 | 59 | _range = Bool(False, help="Display a range selector", sync=True) |
|
59 | 60 | readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) |
|
60 | 61 | slider_color = Unicode(sync=True) |
@@ -63,6 +64,11 b' class FloatSlider(_BoundedFloat):' | |||
|
63 | 64 | class FloatProgress(_BoundedFloat): |
|
64 | 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 | 72 | class _FloatRange(_Float): |
|
67 | 73 | value = Tuple(CFloat, CFloat, default_value=(0.0, 1.0), help="Tuple of (lower, upper) bounds", sync=True) |
|
68 | 74 | lower = CFloat(0.0, help="Lower bound", sync=False) |
@@ -14,7 +14,7 b' Represents an unbounded int using a widget.' | |||
|
14 | 14 | # Imports |
|
15 | 15 | #----------------------------------------------------------------------------- |
|
16 | 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 | 18 | from IPython.utils.warn import DeprecatedClass |
|
19 | 19 | |
|
20 | 20 | #----------------------------------------------------------------------------- |
@@ -58,7 +58,8 b' class BoundedIntText(_BoundedInt):' | |||
|
58 | 58 | class IntSlider(_BoundedInt): |
|
59 | 59 | """Slider widget that represents a int bounded by a minimum and maximum value.""" |
|
60 | 60 | _view_name = Unicode('IntSliderView', sync=True) |
|
61 |
orientation = Enum([ |
|
|
61 | orientation = CaselessStrEnum(values=['horizontal', 'vertical'], | |
|
62 | default_value='horizontal', allow_none=False, | |
|
62 | 63 | help="Vertical or horizontal.", sync=True) |
|
63 | 64 | _range = Bool(False, help="Display a range selector", sync=True) |
|
64 | 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 | 70 | """Progress bar that represents a int bounded by a minimum and maximum value.""" |
|
70 | 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 | 78 | class _IntRange(_Int): |
|
73 | 79 | value = Tuple(CInt, CInt, default_value=(0, 1), help="Tuple of (lower, upper) bounds", sync=True) |
|
74 | 80 | lower = CInt(0, help="Lower bound", sync=False) |
@@ -18,7 +18,7 b' from collections import OrderedDict' | |||
|
18 | 18 | from threading import Lock |
|
19 | 19 | |
|
20 | 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 | 22 | from IPython.utils.py3compat import unicode_type |
|
23 | 23 | from IPython.utils.warn import DeprecatedClass |
|
24 | 24 | |
@@ -125,6 +125,11 b' class Dropdown(_Selection):' | |||
|
125 | 125 | """Allows you to select a single item from a dropdown.""" |
|
126 | 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 | 134 | class RadioButtons(_Selection): |
|
130 | 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