Skip to content

Commit 5ab042f

Browse files
authored
Merge pull request #3510 from jasongrout/tooltip2
Add deprecated description_tooltip for backwards compatibility.
2 parents 763dbb9 + c0c152d commit 5ab042f

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

docs/source/migration_guides.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Migrating custom widget libraries
22
=================================
33

4-
These are migration guides aimed specifically at developers of third-party
4+
These are migration guides specifically for developers of third-party
55
widgets.
66

77
Migrating from 7.x to 8.0

docs/source/user_migration_guides.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Migrating user code
22
===================
33

4-
These are migration guides aimed specifically at user of ipywidgets.
4+
These are migration guides specifically for ipywidgets users.
55

66
Migrating from 7.x to 8.0
77
-------------------------
@@ -30,12 +30,10 @@ to wrap reads from the widget.
3030

3131
As part of an effort to make it possible to
3232
[set tooltips for all widgets](https://github.com/jupyter-widgets/ipywidgets/pull/2680),
33-
the old `description_tooltip` attribute for certain widgets was removed. Now all widgets
33+
the old `description_tooltip` attribute for certain widgets was deprecated. Now all widgets
3434
that inherit `DOMWidget` have the attribute `tooltip` instead.
3535

3636
Suggested migration: Search and replace `description_tooltip` to `tooltip`.
37-
TBD: ipywidgets should add a `description_tooltip` keyword argument to `DescriptionWidget`s, with
38-
a deprecation warning.
3937

4038
#### Selection Widgets
4139

@@ -87,6 +85,7 @@ attribute `data-jupyter-widgets-cdn` on the HTML manager script tag. See
8785

8886
#### widgetsnbextension
8987

90-
The `widgetsnbextension` package is no longer a dependency of `ipywidgets`. Consequently,
91-
neither is the `notebook` package. If you need to keep `notebook` and widget support for it
92-
you will need to ensure they are explicitly stated in any environment bootstrapping.
88+
The `notebook` package is no longer a dependency of the `widgetsnbextension`
89+
package (therefore `notebook` is no longer a dependency of `ipywidgets`). If you
90+
need to install `notebook` with `ipywidgets`, you will need to install
91+
`notebook` explicitly.

python/ipywidgets/ipywidgets/widgets/widget_description.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .widget_style import Style
1010
from .widget_core import CoreWidget
1111
from .domwidget import DOMWidget
12+
import warnings
1213

1314
@register
1415
class DescriptionStyle(Style, CoreWidget, Widget):
@@ -24,6 +25,13 @@ class DescriptionWidget(DOMWidget, CoreWidget):
2425
description_allow_html = Bool(False, help="Accept HTML in the description.").tag(sync=True)
2526
style = InstanceDict(DescriptionStyle, help="Styling customizations").tag(sync=True, **widget_serialization)
2627

28+
def __init__(self, *args, **kwargs):
29+
if 'description_tooltip' in kwargs:
30+
warnings.warn("the description_tooltip argument is deprecated, use tooltip instead", DeprecationWarning)
31+
kwargs.setdefault('tooltip', kwargs['description_tooltip'])
32+
del kwargs['description_tooltip']
33+
super().__init__(*args, **kwargs)
34+
2735
def _repr_keys(self):
2836
for key in super()._repr_keys():
2937
# Exclude style if it had the default value
@@ -32,3 +40,17 @@ def _repr_keys(self):
3240
if repr(value) == '%s()' % value.__class__.__name__:
3341
continue
3442
yield key
43+
44+
@property
45+
def description_tooltip(self):
46+
"""The tooltip information.
47+
.. deprecated :: 8.0.0
48+
Use tooltip attribute instead.
49+
"""
50+
warnings.warn(".description_tooltip is deprecated, use .tooltip instead", DeprecationWarning)
51+
return self.tooltip
52+
53+
@description_tooltip.setter
54+
def description_tooltip(self, tooltip):
55+
warnings.warn(".description_tooltip is deprecated, use .tooltip instead", DeprecationWarning)
56+
self.tooltip = tooltip

0 commit comments

Comments
 (0)