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
Wed May 30 19:34:12 EDT 2018


On 30May2018 21:29, MRAB <python at mrabarnett.plus.com> wrote:
>On 2018-05-30 21:01, Paul St George wrote:
>>Is this equivalent?
>>p = subprocess.Popen('display',  + imagepath)
>>
>p = subprocess.Popen(['display',  imagepath])
>
>>so
>>
>>p = subprocess.Popen('display',  'test.png')
>>
>p = subprocess.Popen(['display',  'test.png'])
>
>Remembering to provide the full paths (unless it's/they're on the system's 
>search path).

Personally, I am generally against the "use a full path" advice.

Using a full path to the executable is (a) nonportable because executables may 
be in different places on different systems and (b) obstructive to the user, 
because they may have built or installed  their own version of the app for 
specific purposes, such as the vendor provided version being out of date.

For example, Paul's problem might also be addressable by writing his own 
"display" shell script invoking the tool of his choice. Like Python, the 
executable command name is a dynamic lookup!

IMO it is the programme caller's task to provide the execution environment, and 
the programme should expect $PATH (UNIX execution search path) to be suitable 
already.

Every hardwired path is a maintenance and fragility nightmare.

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



More information about the Python-list mailing list