gh-118225: Support more options for copying images in Tkinter (GH-118228)

* Add the PhotoImage method copy_replace() to copy a region
  from one image to other image, possibly with pixel zooming and/or
  subsampling.
* Add from_coords parameter to PhotoImage methods copy(), zoom() and subsample().
* Add zoom and subsample parameters to PhotoImage method copy().
This commit is contained in:
Serhiy Storchaka 2024-05-06 17:33:15 +03:00 committed by GitHub
parent 09871c9223
commit 1b639a04ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 271 additions and 20 deletions

View file

@ -979,6 +979,15 @@ of :class:`tkinter.Image`:
Either type of image is created through either the ``file`` or the ``data``
option (other options are available as well).
.. versionchanged:: 3.13
Added the :class:`!PhotoImage` method :meth:`!copy_replace` to copy a region
from one image to other image, possibly with pixel zooming and/or
subsampling.
Add *from_coords* parameter to :class:`!PhotoImage` methods :meth:`!copy()`,
:meth:`!zoom()` and :meth:`!subsample()`.
Add *zoom* and *subsample* parameters to :class:`!PhotoImage` method
:meth:`!copy()`.
The image object can then be used wherever an ``image`` option is supported by
some widget (e.g. labels, buttons, menus). In these cases, Tk will not keep a
reference to the image. When the last Python reference to the image object is