Show More
@@ -325,6 +325,7 b' define([' | |||||
325 | .html(item_html) |
|
325 | .html(item_html) | |
326 | .appendTo(that.$buttongroup) |
|
326 | .appendTo(that.$buttongroup) | |
327 | .attr('data-value', encodeURIComponent(item)) |
|
327 | .attr('data-value', encodeURIComponent(item)) | |
|
328 | .attr('data-toggle', 'tooltip') | |||
328 | .attr('value', item) |
|
329 | .attr('value', item) | |
329 | .on('click', $.proxy(that.handle_click, that)); |
|
330 | .on('click', $.proxy(that.handle_click, that)); | |
330 | that.update_style_traits($item_element); |
|
331 | that.update_style_traits($item_element); | |
@@ -334,7 +335,8 b' define([' | |||||
334 | } else { |
|
335 | } else { | |
335 | $item_element.removeClass('active'); |
|
336 | $item_element.removeClass('active'); | |
336 | } |
|
337 | } | |
337 |
$item_element.prop('disabled', disabled); |
|
338 | $item_element.prop('disabled', disabled); | |
|
339 | $item_element.attr('title', that.model.get('tooltips')[index]); | |||
338 | }); |
|
340 | }); | |
339 |
|
341 | |||
340 | // Remove items that no longer exist. |
|
342 | // Remove items that no longer exist. |
@@ -19,7 +19,7 b' from threading import Lock' | |||||
19 |
|
19 | |||
20 | from .widget import DOMWidget, register |
|
20 | from .widget import DOMWidget, register | |
21 | from IPython.utils.traitlets import ( |
|
21 | from IPython.utils.traitlets import ( | |
22 | Unicode, Bool, Any, Dict, TraitError, CaselessStrEnum, Tuple |
|
22 | Unicode, Bool, Any, Dict, TraitError, CaselessStrEnum, Tuple, List | |
23 | ) |
|
23 | ) | |
24 | from IPython.utils.py3compat import unicode_type |
|
24 | from IPython.utils.py3compat import unicode_type | |
25 | from IPython.utils.warn import DeprecatedClass |
|
25 | from IPython.utils.warn import DeprecatedClass | |
@@ -32,6 +32,12 b' class _Selection(DOMWidget):' | |||||
32 |
|
32 | |||
33 | ``options`` can be specified as a list or dict. If given as a list, |
|
33 | ``options`` can be specified as a list or dict. If given as a list, | |
34 | it will be transformed to a dict of the form ``{str(value):value}``. |
|
34 | it will be transformed to a dict of the form ``{str(value):value}``. | |
|
35 | ||||
|
36 | When programmatically setting the value, a reverse lookup is performed | |||
|
37 | among the options to set the value of ``selected_label`` accordingly. The | |||
|
38 | reverse lookup uses the equality operator by default, but an other | |||
|
39 | predicate may be provided via the ``equals`` argument. For example, when | |||
|
40 | dealing with numpy arrays, one may set equals=np.array_equal. | |||
35 | """ |
|
41 | """ | |
36 |
|
42 | |||
37 | value = Any(help="Selected value") |
|
43 | value = Any(help="Selected value") | |
@@ -194,6 +200,7 b' class ToggleButtons(_Selection):' | |||||
194 | """Group of toggle buttons that represent an enumeration. Only one toggle |
|
200 | """Group of toggle buttons that represent an enumeration. Only one toggle | |
195 | button can be toggled at any point in time.""" |
|
201 | button can be toggled at any point in time.""" | |
196 | _view_name = Unicode('ToggleButtonsView', sync=True) |
|
202 | _view_name = Unicode('ToggleButtonsView', sync=True) | |
|
203 | tooltips = List(Unicode(), sync=True) | |||
197 |
|
204 | |||
198 | button_style = CaselessStrEnum( |
|
205 | button_style = CaselessStrEnum( | |
199 | values=['primary', 'success', 'info', 'warning', 'danger', ''], |
|
206 | values=['primary', 'success', 'info', 'warning', 'danger', ''], |
General Comments 0
You need to be logged in to leave comments.
Login now