Last active
January 28, 2019 19:39
-
-
Save kogcyc/6865469c7c5e3dde06e9a0b35b0f28a7 to your computer and use it in GitHub Desktop.
use Python to display a bitmap when it is modifed (saved)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
from PIL import Image | |
import psutil | |
filename = './rectangle.png' | |
modifiedTime = os.stat(filename).st_mtime | |
while True: | |
time.sleep(0.1) | |
checkTime = os.stat(filename).st_mtime | |
if (checkTime != modifiedTime): | |
modifiedTime = checkTime | |
print(time.strftime('%Y %m %d %H%M%S', time.localtime())) | |
for proc in psutil.process_iter(): | |
if proc.name() == "display": | |
proc.kill() | |
im = Image.open(filename) | |
im.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment