mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Added delay after opening image with xdg-open
This commit is contained in:
		
							parent
							
								
									143032103c
								
							
						
					
					
						commit
						10c4f75aaa
					
				| 
						 | 
					@ -126,6 +126,16 @@ class Viewer:
 | 
				
			||||||
        os.system(self.get_command(path, **options))
 | 
					        os.system(self.get_command(path, **options))
 | 
				
			||||||
        return 1
 | 
					        return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _remove_path_after_delay(self, path):
 | 
				
			||||||
 | 
					        subprocess.Popen(
 | 
				
			||||||
 | 
					            [
 | 
				
			||||||
 | 
					                sys.executable,
 | 
				
			||||||
 | 
					                "-c",
 | 
				
			||||||
 | 
					                "import os, sys, time; time.sleep(20); os.remove(sys.argv[1])",
 | 
				
			||||||
 | 
					                path,
 | 
				
			||||||
 | 
					            ]
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# --------------------------------------------------------------------
 | 
					# --------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -180,14 +190,7 @@ class MacViewer(Viewer):
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                raise TypeError("Missing required argument: 'path'")
 | 
					                raise TypeError("Missing required argument: 'path'")
 | 
				
			||||||
        subprocess.call(["open", "-a", "Preview.app", path])
 | 
					        subprocess.call(["open", "-a", "Preview.app", path])
 | 
				
			||||||
        subprocess.Popen(
 | 
					        self._remove_path_after_delay(path)
 | 
				
			||||||
            [
 | 
					 | 
				
			||||||
                sys.executable,
 | 
					 | 
				
			||||||
                "-c",
 | 
					 | 
				
			||||||
                "import os, sys, time; time.sleep(20); os.remove(sys.argv[1])",
 | 
					 | 
				
			||||||
                path,
 | 
					 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        )
 | 
					 | 
				
			||||||
        return 1
 | 
					        return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -232,7 +235,7 @@ class XDGViewer(UnixViewer):
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                raise TypeError("Missing required argument: 'path'")
 | 
					                raise TypeError("Missing required argument: 'path'")
 | 
				
			||||||
        subprocess.Popen(["xdg-open", path])
 | 
					        subprocess.Popen(["xdg-open", path])
 | 
				
			||||||
        os.remove(path)
 | 
					        self._remove_path_after_delay(path)
 | 
				
			||||||
        return 1
 | 
					        return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user