- くだすれPython(超初心者用) その22
925 :デフォルトの名無しさん[sage]:2014/05/14(水) 17:48:47.03 ID:TLDxGDFZ - from subprocess import check_output, CalledProcessError
from datetime import datetime from tkinter import Label from time import sleep msg = "Firefoxを使い始めてから\n10分経ちました" while True: try: x = check_output(["pidof", "firefox"]) pid = x.decode().rstrip() y = check_output(["ps", "-p", pid, "-o", "etime"]) str_etime = y.decode().strip(" ").strip("ELAPSED").strip("\n").strip(" ") etime = datetime.strptime(str_etime, "%M:%S") if etime.minute >= 10: label = Label(None, text=msg, font=("sans-serif", 16)) label.pack(padx=8, pady=8) label.mainloop() sleep(30) except CalledProcessError: sleep(30) 結局、こういう感じになった 昨日教えてくれた人ありがとう これ裏で動かしても重くならないよね?
|