The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?
Christian Gollwitzer
auriocus at gmx.de
Mon May 28 00:34:30 EDT 2018
Am 27.05.18 um 23:58 schrieb Cameron Simpson:
> On 27May2018 20:15, Paul St George <email at paulstgeorge.com> wrote:
>> This is very helpful indeed, thank you. Awe-inspiring.
>>
>> It occurred to me that I could edit the PIL/ImageShow.py, replacing
>> ‘xv’ (in five places) with the utility of my choice and using
>> ‘executable’ as the command.
>>
>> Or, is this just not done?
>
> It becomes a maintenance problem.
>
> Alternatively you could:
>
> Just write your own show function which accepts an Image and displays it
> with your program of choice. You might need to write some equivalent
> code which saves the Image to a file first, and removes it afterwards.
>
> You could copy the show() code into a function of your own (i.e. in your
> own codebase) modify that to suit, then monkeypatch the class:
>
> Image.show = your_personal_show_function
>
> when your programme starts. That way the code changes are not in the PIL
> code.
I think this is a bug/misfeature in the PIL code. On all 3 major
platforms there is a way to invoke the standard program for a given file
or URL. On Windows, it is "cmd.exe /c start ...", on OSX it is "open
...." and on Linux it is "xdg-open ...". That way the file is opened by
whatever the user has set in his desktop environment.
Technically, xdg-open needs not to be present on Linux, though it is
usually installed.
Christian
More information about the Python-list
mailing list