Commits

Long Yang committed 60e7da9

add curdir

Comments (0)

Files changed (1)

     root.after(period, log)
     btn['state'] = DISABLED
     try:
-        os.mkdir(time.strftime('%y-%m-%d'))
+        os.mkdir(curdir+os.sep+time.strftime('%y-%m-%d'))
     except:pass
     
 def log():
-    global t
-    t = time.strftime('%Y-%m-%d_%H:%M:%S')
     root.wm_attributes('-alpha', 1)
     root.wm_attributes('-topmost', 1)
     e.selection_range(0, END)
     root.after(period, log)
     
 def save(event):
-    fn = time.strftime('%y-%m-%d')+os.sep+'activity.txt'
+    t = time.strftime('%Y-%m-%d_%H:%M:%S')
+    fn = curdir+os.sep+time.strftime('%y-%m-%d')+os.sep+'activity.txt'
     f = open(fn, 'ab+')
     w = csv.writer(f)
     w.writerow((t, e.get()))
     root.wm_attributes('-alpha', 0)
     
     im = ImageGrab.grab()
-    im.save(time.strftime('%y-%m-%d')+os.sep+time.strftime('%H-%M-%S')+'.jpg', "JPEG")
+    im.save(curdir+os.sep+time.strftime('%y-%m-%d')+os.sep+time.strftime('%H-%M-%S')+'.jpg', "JPEG")
     
 if __name__ == '__main__':
     root = Tk()
     e.insert(0, '30')
     
     period = 0
-    t = ''
+    curdir = os.path.dirname(os.path.abspath(__file__))
     
     btn = Button(root, text='start', command=start)
     btn.pack()