Skip to content

Commit 04bac14

Browse files
committed
Add deprecated description_tooltip for backwards compatibility.
This follows up on #2680 to help users transition to this backwards-incompatible change.
1 parent 763dbb9 commit 04bac14

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

docs/source/user_migration_guides.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

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)