mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-06 05:20:09 +03:00
Merge c3d9501838
into 5b260bd48b
This commit is contained in:
commit
8ffbc61b56
|
@ -40,15 +40,25 @@ def register(viewer, order=1):
|
||||||
#
|
#
|
||||||
# @param image An image object.
|
# @param image An image object.
|
||||||
# @param title Optional title. Not all viewers can display the title.
|
# @param title Optional title. Not all viewers can display the title.
|
||||||
|
# @param command Optional command. Command to display the image with.
|
||||||
# @param **options Additional viewer options.
|
# @param **options Additional viewer options.
|
||||||
# @return True if a suitable viewer was found, false otherwise.
|
# @return True if a suitable viewer was found, false otherwise.
|
||||||
|
|
||||||
def show(image, title=None, **options):
|
def show(image, title=None, command=None, **options):
|
||||||
|
if command is not None:
|
||||||
|
return _showWithCommand(image,command,title=title,**options)
|
||||||
for viewer in _viewers:
|
for viewer in _viewers:
|
||||||
if viewer.show(image, title=title, **options):
|
if viewer.show(image, title=title, **options):
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def _showWithCommand(image,command,**options):
|
||||||
|
viewer = SimpleCommandViewer(command)
|
||||||
|
#TODO: Should we register these viewers and see if there is already a
|
||||||
|
#viewer for this command?
|
||||||
|
viewer.show(image,**options)
|
||||||
|
return True
|
||||||
|
|
||||||
##
|
##
|
||||||
# Base class for viewers.
|
# Base class for viewers.
|
||||||
|
|
||||||
|
@ -108,6 +118,9 @@ if sys.platform == "win32":
|
||||||
|
|
||||||
register(WindowsViewer)
|
register(WindowsViewer)
|
||||||
|
|
||||||
|
class SimpleCommandViewer(WindowsViewer):
|
||||||
|
pass
|
||||||
|
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
|
|
||||||
class MacViewer(Viewer):
|
class MacViewer(Viewer):
|
||||||
|
@ -121,6 +134,9 @@ elif sys.platform == "darwin":
|
||||||
|
|
||||||
register(MacViewer)
|
register(MacViewer)
|
||||||
|
|
||||||
|
class SimpleCommandViewer(MacViewer):
|
||||||
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# unixoids
|
# unixoids
|
||||||
|
@ -145,6 +161,15 @@ else:
|
||||||
|
|
||||||
# implementations
|
# implementations
|
||||||
|
|
||||||
|
class SimpleCommandViewer(UnixViewer):
|
||||||
|
def __init__(self,command):
|
||||||
|
super(SimpleCommandViewer, self).__init__()
|
||||||
|
self._command = command
|
||||||
|
|
||||||
|
def get_command_ex(self, file, **options):
|
||||||
|
command = executable = self._command
|
||||||
|
return command, executable
|
||||||
|
|
||||||
class DisplayViewer(UnixViewer):
|
class DisplayViewer(UnixViewer):
|
||||||
def get_command_ex(self, file, **options):
|
def get_command_ex(self, file, **options):
|
||||||
command = executable = "display"
|
command = executable = "display"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user