Tooltips in togglebuttons

Sylvain Corlay 11 years ago
parent da96d28620
commit 829d25bdfd

@ -325,6 +325,7 @@ define([
.html(item_html)
.appendTo(that.$buttongroup)
.attr('data-value', encodeURIComponent(item))
.attr('data-toggle', 'tooltip')
.attr('value', item)
.on('click', $.proxy(that.handle_click, that));
that.update_style_traits($item_element);
@ -334,7 +335,8 @@ define([
} else {
$item_element.removeClass('active');
}
$item_element.prop('disabled', disabled);
$item_element.prop('disabled', disabled);
$item_element.attr('title', that.model.get('tooltips')[index]);
});
// Remove items that no longer exist.

@ -19,7 +19,7 @@ from threading import Lock
from .widget import DOMWidget, register
from IPython.utils.traitlets import (
Unicode, Bool, Any, Dict, TraitError, CaselessStrEnum, Tuple
Unicode, Bool, Any, Dict, TraitError, CaselessStrEnum, Tuple, List
)
from IPython.utils.py3compat import unicode_type
from IPython.utils.warn import DeprecatedClass
@ -32,6 +32,12 @@ class _Selection(DOMWidget):
``options`` can be specified as a list or dict. If given as a list,
it will be transformed to a dict of the form ``{str(value):value}``.
When programmatically setting the value, a reverse lookup is performed
among the options to set the value of ``selected_label`` accordingly. The
reverse lookup uses the equality operator by default, but an other
predicate may be provided via the ``equals`` argument. For example, when
dealing with numpy arrays, one may set equals=np.array_equal.
"""
value = Any(help="Selected value")
@ -194,6 +200,7 @@ class ToggleButtons(_Selection):
"""Group of toggle buttons that represent an enumeration. Only one toggle
button can be toggled at any point in time."""
_view_name = Unicode('ToggleButtonsView', sync=True)
tooltips = List(Unicode(), sync=True)
button_style = CaselessStrEnum(
values=['primary', 'success', 'info', 'warning', 'danger', ''],

Loading…
Cancel
Save