mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-20 04:04:45 +03:00
Viewer class properties: src/PIL/ImageShow.py, Tests/test_imageshow.py files changed:
- Viewer class format property changed to 'PNG', format property removed from child classes. - Viewer class options property changed to {"compress_level": 1}, format property removed from child classes. - IPythonViewer format option set to None, IPythonViewer options set to {}. - Corresponding test Tests/test_imageshow.py::test_viewer changed to meet the changes mentioned above.
This commit is contained in:
parent
71839a7623
commit
b348881de4
|
@ -54,7 +54,7 @@ def test_show():
|
|||
def test_viewer():
|
||||
viewer = ImageShow.Viewer()
|
||||
|
||||
assert viewer.get_format(None) is None
|
||||
assert viewer.get_format(None) == "PNG"
|
||||
|
||||
with pytest.raises(NotImplementedError):
|
||||
viewer.get_command(None)
|
||||
|
|
|
@ -61,6 +61,11 @@ def show(image, title=None, **options):
|
|||
class Viewer:
|
||||
"""Base class for viewers."""
|
||||
|
||||
format = "PNG"
|
||||
"""The format to convert the image into."""
|
||||
options = {"compress_level": 1}
|
||||
"""Additional options used to convert the image."""
|
||||
|
||||
# main api
|
||||
|
||||
def show(self, image, **options):
|
||||
|
@ -81,11 +86,6 @@ class Viewer:
|
|||
|
||||
# hook methods
|
||||
|
||||
format = None
|
||||
"""The format to convert the image into."""
|
||||
options = {}
|
||||
"""Additional options used to convert the image."""
|
||||
|
||||
def get_format(self, image):
|
||||
"""Return format name, or ``None`` to save as PGM/PPM."""
|
||||
return self.format
|
||||
|
@ -143,9 +143,6 @@ class Viewer:
|
|||
class WindowsViewer(Viewer):
|
||||
"""The default viewer on Windows is the default system application for PNG files."""
|
||||
|
||||
format = "PNG"
|
||||
options = {"compress_level": 1}
|
||||
|
||||
def get_command(self, file, **options):
|
||||
return (
|
||||
f'start "Pillow" /WAIT "{file}" '
|
||||
|
@ -161,9 +158,6 @@ if sys.platform == "win32":
|
|||
class MacViewer(Viewer):
|
||||
"""The default viewer on macOS using ``Preview.app``."""
|
||||
|
||||
format = "PNG"
|
||||
options = {"compress_level": 1}
|
||||
|
||||
def get_command(self, file, **options):
|
||||
# on darwin open returns immediately resulting in the temp
|
||||
# file removal while app is opening
|
||||
|
@ -199,9 +193,6 @@ if sys.platform == "darwin":
|
|||
|
||||
|
||||
class UnixViewer(Viewer):
|
||||
format = "PNG"
|
||||
options = {"compress_level": 1}
|
||||
|
||||
def get_command(self, file, **options):
|
||||
command = self.get_command_ex(file, **options)[0]
|
||||
return f"({command} {quote(file)}; rm -f {quote(file)})&"
|
||||
|
@ -395,6 +386,9 @@ if sys.platform not in ("win32", "darwin"): # unixoids
|
|||
class IPythonViewer(Viewer):
|
||||
"""The viewer for IPython frontends."""
|
||||
|
||||
format = None
|
||||
options = {}
|
||||
|
||||
def show_image(self, image, **options):
|
||||
ipython_display(image)
|
||||
return 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user