Skip to content

Commit

Permalink
Added delay after opening image with xdg-open
Browse files Browse the repository at this point in the history
radarhere committed Feb 2, 2022

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent ca0b585 commit 02affaa
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/PIL/ImageShow.py
Original file line number Diff line number Diff line change
@@ -105,10 +105,20 @@ def show_image(self, image, **options):
return self.show_file(self.save_image(image), **options)

def show_file(self, file, **options):
"""Display the given file."""
"""Display given file"""
os.system(self.get_command(file, **options))
return 1

def _remove_file_after_delay(self, file):
subprocess.Popen(
[
sys.executable,
"-c",
"import os, sys, time; time.sleep(20); os.remove(sys.argv[1])",
file,
]
)


# --------------------------------------------------------------------

@@ -147,14 +157,7 @@ def get_command(self, file, **options):
def show_file(self, file, **options):
"""Display given file"""
subprocess.call(["open", "-a", "Preview.app", file])
subprocess.Popen(
[
sys.executable,
"-c",
"import os, sys, time; time.sleep(20); os.remove(sys.argv[1])",
file,
]
)
self._remove_file_after_delay(file)
return 1


@@ -181,8 +184,9 @@ def get_command_ex(self, file, **options):
return command, executable

def show_file(self, file, **options):
"""Display given file"""
subprocess.Popen(["xdg-open", file])
os.remove(file)
self._remove_file_after_delay(file)
return 1


@@ -199,6 +203,7 @@ def get_command_ex(self, file, title=None, **options):
return command, executable

def show_file(self, file, **options):
"""Display given file"""
args = ["display"]
if "title" in options:
args += ["-name", options["title"]]
@@ -218,6 +223,7 @@ def get_command_ex(self, file, **options):
return command, executable

def show_file(self, file, **options):
"""Display given file"""
subprocess.Popen(["gm", "display", file])
os.remove(file)
return 1
@@ -232,6 +238,7 @@ def get_command_ex(self, file, **options):
return command, executable

def show_file(self, file, **options):
"""Display given file"""
subprocess.Popen(["eog", "-n", file])
os.remove(file)
return 1
@@ -252,6 +259,7 @@ def get_command_ex(self, file, title=None, **options):
return command, executable

def show_file(self, file, **options):
"""Display given file"""
args = ["xv"]
if "title" in options:
args += ["-name", options["title"]]

0 comments on commit 02affaa

Please sign in to comment.