The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

Cameron Simpson cs at cskk.id.au
Sun May 27 17:58:36 EDT 2018


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.

Cheers,
Cameron Simpson <cs at cskk.id.au>



More information about the Python-list mailing list