You can do it like this,i use use webbrowser module.
If not given a url but a path it open my default image viewer(IrfanView) on Windows.
So it will show image for 3-sec and close IrfanView ect..
I do this with subprocess module.
If not given a url but a path it open my default image viewer(IrfanView) on Windows.
So it will show image for 3-sec and close IrfanView ect..
I do this with subprocess module.
import webbrowser import subprocess import os, time for file in os.scandir('.'): if file.name.endswith(('.jpg', '.png')): webbrowser.open(file.name) time.sleep(3) subprocess.run(['taskkill', '/f', '/im', 'i_view32.exe'])
Output:E:\1py_div\image_loop
λ python img.py
SUCCESS: The process "i_view32.exe" with PID 15912 has been terminated.
SUCCESS: The process "i_view32.exe" with PID 20024 has been terminated.
SUCCESS: The process "i_view32.exe" with PID 7376 has been terminated.
SUCCESS: The process "i_view32.exe" with PID 11028 has been terminated.
SUCCESS: The process "i_view32.exe" with PID 13252 has been terminated.
You see it close process,you most find process name for Windows Photo Viewer.