Skip to content

Commit 2c63162

Browse files
committed
Deprecate ImageTk._show
1 parent d7d48df commit 2c63162

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

Tests/test_imagetk.py

+10
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,13 @@ def test_bitmapimage() -> None:
112112

113113
with pytest.raises(ValueError):
114114
ImageTk.BitmapImage()
115+
116+
117+
def test_show_deprecated() -> None:
118+
im = hopper()
119+
120+
with pytest.warns(DeprecationWarning):
121+
try:
122+
ImageTk._show(im, "test")
123+
except tk.TclError:
124+
pass

docs/deprecations.rst

+8
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ Image.Image.get_child_images()
193193
method uses an image's file pointer, and so child images could only be retrieved from
194194
an :py:class:`PIL.ImageFile.ImageFile` instance.
195195

196+
ImageTk._show()
197+
^^^^^^^^^^^^^^^
198+
199+
.. deprecated:: 11.2.0
200+
201+
``ImageTk._show()`` has been deprecated, as it was an unused helper for
202+
:py:meth:`.Image.Image.show`.
203+
196204
Removed features
197205
----------------
198206

docs/releasenotes/11.2.0.rst

+8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ Image.Image.get_child_images()
3333
method uses an image's file pointer, and so child images could only be retrieved from
3434
an :py:class:`PIL.ImageFile.ImageFile` instance.
3535

36+
ImageTk._show()
37+
^^^^^^^^^^^^^^^
38+
39+
.. deprecated:: 11.2.0
40+
41+
``ImageTk._show()`` has been deprecated, as it was an unused helper for
42+
:py:meth:`.Image.Image.show`.
43+
3644
API Changes
3745
===========
3846

src/PIL/ImageTk.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from typing import TYPE_CHECKING, Any, cast
3232

3333
from . import Image, ImageFile
34+
from ._deprecate import deprecate
3435

3536
if TYPE_CHECKING:
3637
from ._typing import CapsuleType
@@ -266,8 +267,6 @@ def getimage(photo: PhotoImage) -> Image.Image:
266267

267268

268269
def _show(image: Image.Image, title: str | None) -> None:
269-
"""Helper for the Image.show method."""
270-
271270
class UI(tkinter.Label):
272271
def __init__(self, master: tkinter.Toplevel, im: Image.Image) -> None:
273272
self.image: BitmapImage | PhotoImage
@@ -281,6 +280,7 @@ def __init__(self, master: tkinter.Toplevel, im: Image.Image) -> None:
281280
image = self.image
282281
super().__init__(master, image=image, bg="black", bd=0)
283282

283+
deprecate("ImageTk._show", 13)
284284
if not getattr(tkinter, "_default_root"):
285285
msg = "tkinter not initialized"
286286
raise OSError(msg)

0 commit comments

Comments
 (0)