Skip to content

Instantly share code, notes, and snippets.

@kogcyc
Last active January 28, 2019 19:39
Show Gist options
  • Save kogcyc/6865469c7c5e3dde06e9a0b35b0f28a7 to your computer and use it in GitHub Desktop.
Save kogcyc/6865469c7c5e3dde06e9a0b35b0f28a7 to your computer and use it in GitHub Desktop.
use Python to display a bitmap when it is modifed (saved)
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