FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-151888: Add tkinter PhotoImage.redither method by serhiy-storchaka · Pull Request #151889 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (3) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 8 additions & 0 deletions Doc/library/tkinter.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6076,6 +6076,14 @@ Image classes
it is displayed as transparent and the background of whatever window it
is displayed in shows through.

.. method:: redither()

Recalculate the dithered image in each window where it is displayed.
This is useful when the image data was supplied in pieces, in which case
the dithered image may not be exactly correct.

.. versionadded:: next

.. method:: cget(option)

Return the current value of the configuration option *option*.
Expand Down
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.16.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ tkinter
badge) and :meth:`~tkinter.Wm.wm_stackorder` (toplevel stacking order).
(Contributed by Serhiy Storchaka in :gh:`151874`.)

* Added the :meth:`~tkinter.PhotoImage.redither` method which recalculates the
dithered image when its data was supplied in pieces.
(Contributed by Serhiy Storchaka in :gh:`151888`.)


xml
---

Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_tkinter/test_images.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ def test_blank(self):
self.assertEqual(image.height(), 16)
self.assertEqual(image.get(4, 6), self.colorlist(0, 0, 0))

def test_redither(self):
image = self.create()
pixel = image.get(4, 6)
image.redither() # Recalculates the dithering; the data is unchanged.
self.assertEqual(image.get(4, 6), pixel)

def test_copy(self):
image = self.create()
image2 = image.copy()
Expand Down
7 changes: 7 additions & 0 deletions Lib/tkinter/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4571,6 +4571,13 @@ def blank(self):
"""Display a transparent image."""
self.tk.call(self.name, 'blank')

def redither(self):
"""Recalculate the dithered image in each window where it is displayed.

Useful when the image data was supplied in pieces, in which case the
dithered image may not be exactly correct."""
self.tk.call(self.name, 'redither')

def cget(self, option):
"""Return the value of OPTION."""
return self.tk.call(self.name, 'cget', '-' + option)
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add the :meth:`!tkinter.PhotoImage.redither` method, wrapping the photo image
``redither`` Tk command.
Loading

Back | FazBrowse Home | New Git URL