diff --git a/Tests/test_imagetk.py b/Tests/test_imagetk.py index 4484dca1064..85ad116510b 100644 --- a/Tests/test_imagetk.py +++ b/Tests/test_imagetk.py @@ -112,3 +112,13 @@ def test_bitmapimage() -> None: with pytest.raises(ValueError): ImageTk.BitmapImage() + + +def test_show_deprecated() -> None: + im = hopper() + + with pytest.warns(DeprecationWarning): + try: + ImageTk._show(im, "test") + except tk.TclError: + pass diff --git a/docs/deprecations.rst b/docs/deprecations.rst index 634cee6894c..6e7a0bf0302 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -193,6 +193,14 @@ Image.Image.get_child_images() method uses an image's file pointer, and so child images could only be retrieved from an :py:class:`PIL.ImageFile.ImageFile` instance. +ImageTk._show() +^^^^^^^^^^^^^^^ + +.. deprecated:: 11.2.0 + +``ImageTk._show()`` has been deprecated, as it was an unused helper for +:py:meth:`.Image.Image.show`. + Removed features ---------------- diff --git a/docs/releasenotes/11.2.0.rst b/docs/releasenotes/11.2.0.rst index f7e644cf32d..7e6a7a534a4 100644 --- a/docs/releasenotes/11.2.0.rst +++ b/docs/releasenotes/11.2.0.rst @@ -33,6 +33,14 @@ Image.Image.get_child_images() method uses an image's file pointer, and so child images could only be retrieved from an :py:class:`PIL.ImageFile.ImageFile` instance. +ImageTk._show() +^^^^^^^^^^^^^^^ + +.. deprecated:: 11.2.0 + +``ImageTk._show()`` has been deprecated, as it was an unused helper for +:py:meth:`.Image.Image.show`. + API Changes =========== diff --git a/src/PIL/ImageTk.py b/src/PIL/ImageTk.py index bf29fdba54c..c0f62cb14e4 100644 --- a/src/PIL/ImageTk.py +++ b/src/PIL/ImageTk.py @@ -31,6 +31,7 @@ from typing import TYPE_CHECKING, Any, cast from . import Image, ImageFile +from ._deprecate import deprecate if TYPE_CHECKING: from ._typing import CapsuleType @@ -266,8 +267,6 @@ def getimage(photo: PhotoImage) -> Image.Image: def _show(image: Image.Image, title: str | None) -> None: - """Helper for the Image.show method.""" - class UI(tkinter.Label): def __init__(self, master: tkinter.Toplevel, im: Image.Image) -> None: self.image: BitmapImage | PhotoImage @@ -281,6 +280,7 @@ def __init__(self, master: tkinter.Toplevel, im: Image.Image) -> None: image = self.image super().__init__(master, image=image, bg="black", bd=0) + deprecate("ImageTk._show", 13) if not getattr(tkinter, "_default_root"): msg = "tkinter not initialized" raise OSError(msg)