diff --git a/IPython/html/widgets/deprecated.py b/IPython/html/widgets/deprecated.py
new file mode 100644
index 000000000..481c08f6f
--- /dev/null
+++ b/IPython/html/widgets/deprecated.py
@@ -0,0 +1,22 @@
+"""Decorator for warning about deprecated widget classes"""
+
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
+
+from warnings import warn
+
+
+def DeprecatedClass(base, class_name):
+ """Warn about a deprecated class on instantiation"""
+ # Hook the init method of the base class.
+ def init_hook(self, *pargs, **kwargs):
+ base.__init__(self, *pargs, **kwargs)
+
+ # Warn once per class.
+ if base not in DeprecatedClass._warned_classes:
+ DeprecatedClass._warned_classes.append(base)
+ warn('"{}" is deprecated, please use "{}" instead.'.format(
+ class_name, base.__name__))
+ return type(class_name, (base,), {'__init__': init_hook})
+
+DeprecatedClass._warned_classes = []
diff --git a/IPython/html/widgets/widget_bool.py b/IPython/html/widgets/widget_bool.py
index a74aacc32..ea897b5fc 100644
--- a/IPython/html/widgets/widget_bool.py
+++ b/IPython/html/widgets/widget_bool.py
@@ -1,25 +1,16 @@
-"""Bool class.
+"""Bool class.
Represents a boolean using a widget.
"""
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, the IPython Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
+
from .widget import DOMWidget, register
from IPython.utils.traitlets import Unicode, Bool, CaselessStrEnum
-from IPython.utils.warn import DeprecatedClass
+from .deprecated import DeprecatedClass
+
-#-----------------------------------------------------------------------------
-# Classes
-#-----------------------------------------------------------------------------
class _Bool(DOMWidget):
"""A base class for creating widgets that represent booleans."""
value = Bool(False, help="Bool value", sync=True)
diff --git a/IPython/html/widgets/widget_box.py b/IPython/html/widgets/widget_box.py
index 7ae342e2e..b751f894f 100644
--- a/IPython/html/widgets/widget_box.py
+++ b/IPython/html/widgets/widget_box.py
@@ -8,7 +8,7 @@ Represents a container that can be used to group other widgets.
from .widget import DOMWidget, Widget, register
from IPython.utils.traitlets import Unicode, Tuple, TraitError, Int, CaselessStrEnum
-from IPython.utils.warn import DeprecatedClass
+from .deprecated import DeprecatedClass
def _widget_to_json(x):
if isinstance(x, dict):
diff --git a/IPython/html/widgets/widget_button.py b/IPython/html/widgets/widget_button.py
index 3b3ad66da..a2692f4f1 100644
--- a/IPython/html/widgets/widget_button.py
+++ b/IPython/html/widgets/widget_button.py
@@ -1,26 +1,17 @@
-"""Button class.
+"""Button class.
Represents a button in the frontend using a widget. Allows user to listen for
click events on the button and trigger backend code when the clicks are fired.
"""
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, the IPython Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
+
from .widget import DOMWidget, CallbackDispatcher, register
from IPython.utils.traitlets import Unicode, Bool, CaselessStrEnum
-from IPython.utils.warn import DeprecatedClass
+from .deprecated import DeprecatedClass
+
-#-----------------------------------------------------------------------------
-# Classes
-#-----------------------------------------------------------------------------
@register('IPython.Button')
class Button(DOMWidget):
"""Button widget.
diff --git a/IPython/html/widgets/widget_float.py b/IPython/html/widgets/widget_float.py
index a7cf157f6..914552adc 100644
--- a/IPython/html/widgets/widget_float.py
+++ b/IPython/html/widgets/widget_float.py
@@ -2,26 +2,17 @@
Represents an unbounded float using a widget.
"""
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, the IPython Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
+
from .widget import DOMWidget, register
from .trait_types import Color
from IPython.utils.traitlets import (Unicode, CFloat, Bool, CaselessStrEnum,
Tuple, TraitError)
-from IPython.utils.warn import DeprecatedClass
+from .deprecated import DeprecatedClass
+
-#-----------------------------------------------------------------------------
-# Classes
-#-----------------------------------------------------------------------------
class _Float(DOMWidget):
value = CFloat(0.0, help="Float value", sync=True)
disabled = Bool(False, help="Enable or disable user changes", sync=True)
diff --git a/IPython/html/widgets/widget_image.py b/IPython/html/widgets/widget_image.py
index 40968f03d..06b1f03ec 100644
--- a/IPython/html/widgets/widget_image.py
+++ b/IPython/html/widgets/widget_image.py
@@ -1,27 +1,17 @@
-"""Image class.
+"""Image class.
Represents an image in the frontend using a widget.
"""
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, the IPython Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
+
import base64
from .widget import DOMWidget, register
from IPython.utils.traitlets import Unicode, CUnicode, Bytes
-from IPython.utils.warn import DeprecatedClass
+from .deprecated import DeprecatedClass
-#-----------------------------------------------------------------------------
-# Classes
-#-----------------------------------------------------------------------------
@register('IPython.Image')
class Image(DOMWidget):
"""Displays an image as a widget.
diff --git a/IPython/html/widgets/widget_int.py b/IPython/html/widgets/widget_int.py
index e76f26be7..d7b146c80 100644
--- a/IPython/html/widgets/widget_int.py
+++ b/IPython/html/widgets/widget_int.py
@@ -2,26 +2,17 @@
Represents an unbounded int using a widget.
"""
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, the IPython Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
+
from .widget import DOMWidget, register
from .trait_types import Color
from IPython.utils.traitlets import (Unicode, CInt, Bool, CaselessStrEnum,
Tuple, TraitError)
-from IPython.utils.warn import DeprecatedClass
+from .deprecated import DeprecatedClass
+
-#-----------------------------------------------------------------------------
-# Classes
-#-----------------------------------------------------------------------------
class _Int(DOMWidget):
"""Base class used to create widgets that represent an int."""
value = CInt(0, help="Int value", sync=True)
diff --git a/IPython/html/widgets/widget_selection.py b/IPython/html/widgets/widget_selection.py
index 091ed41ea..3f7561d30 100644
--- a/IPython/html/widgets/widget_selection.py
+++ b/IPython/html/widgets/widget_selection.py
@@ -2,17 +2,9 @@
Represents an enumeration using a widget.
"""
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, the IPython Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
from collections import OrderedDict
from threading import Lock
@@ -22,11 +14,9 @@ from IPython.utils.traitlets import (
Unicode, Bool, Any, Dict, TraitError, CaselessStrEnum, Tuple, List
)
from IPython.utils.py3compat import unicode_type
-from IPython.utils.warn import DeprecatedClass
+from .deprecated import DeprecatedClass
+
-#-----------------------------------------------------------------------------
-# SelectionWidget
-#-----------------------------------------------------------------------------
class _Selection(DOMWidget):
"""Base class for Selection widgets
diff --git a/IPython/html/widgets/widget_selectioncontainer.py b/IPython/html/widgets/widget_selectioncontainer.py
index 42adec053..e6df2e68c 100644
--- a/IPython/html/widgets/widget_selectioncontainer.py
+++ b/IPython/html/widgets/widget_selectioncontainer.py
@@ -3,24 +3,14 @@
Represents a multipage container that can be used to group other widgets into
pages.
"""
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, the IPython Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
+
from .widget_box import Box, register
from IPython.utils.traitlets import Unicode, Dict, CInt
-from IPython.utils.warn import DeprecatedClass
+from .deprecated import DeprecatedClass
-#-----------------------------------------------------------------------------
-# Classes
-#-----------------------------------------------------------------------------
class _SelectionContainer(Box):
"""Base class used to display multiple child widgets."""
_titles = Dict(help="Titles of the pages", sync=True)
diff --git a/IPython/html/widgets/widget_string.py b/IPython/html/widgets/widget_string.py
index 96d7d4408..a71f58954 100644
--- a/IPython/html/widgets/widget_string.py
+++ b/IPython/html/widgets/widget_string.py
@@ -1,25 +1,16 @@
-"""String class.
+"""String class.
Represents a unicode string using a widget.
"""
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, the IPython Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
+# Copyright (c) IPython Development Team.
+# Distributed under the terms of the Modified BSD License.
+
from .widget import DOMWidget, CallbackDispatcher, register
from IPython.utils.traitlets import Unicode, Bool
-from IPython.utils.warn import DeprecatedClass
+from .deprecated import DeprecatedClass
+
-#-----------------------------------------------------------------------------
-# Classes
-#-----------------------------------------------------------------------------
class _String(DOMWidget):
"""Base class used to create widgets that represent a string."""
value = Unicode(help="String value", sync=True)