Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated PhotoImage.paste() box parameter #6178

Merged
merged 2 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions Tests/test_imagetk.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def test_photoimage_blank():
assert_image_equal(reloaded.convert(mode), im)


def test_box_deprecation():
im = hopper()
im_tk = ImageTk.PhotoImage(im)
with pytest.warns(DeprecationWarning):
im_tk.paste(im, (0, 0, 128, 128))


def test_bitmapimage():
im = hopper("1")

Expand Down
7 changes: 7 additions & 0 deletions docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ The stub image plugin ``FitsStubImagePlugin`` has been deprecated and will be re
Pillow 10.0.0 (2023-07-01). FITS images can be read without a handler through
:mod:`~PIL.FitsImagePlugin` instead.

PhotoImage.paste box parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 9.2.0

The ``box`` parameter is unused. It will be removed in Pillow 10.0.0 (2023-07-01).

Removed features
----------------

Expand Down
11 changes: 8 additions & 3 deletions src/PIL/ImageTk.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#

import tkinter
import warnings
from io import BytesIO

from . import Image
Expand Down Expand Up @@ -183,11 +184,15 @@ def paste(self, im, box=None):
:param im: A PIL image. The size must match the target region. If the
mode does not match, the image is converted to the mode of
the bitmap image.
:param box: A 4-tuple defining the left, upper, right, and lower pixel
coordinate. See :ref:`coordinate-system`. If None is given
instead of a tuple, all of the image is assumed.
"""

if box is not None:
warnings.warn(
"The box parameter is deprecated and will be removed in Pillow 10 "
"(2023-07-01).",
DeprecationWarning,
)

# convert to blittable
im.load()
image = im.im
Expand Down