I am trying to make that every screenshot file end with a date. It does work, but the problem is that when i take a new screenshot, its always the same date.
Heres the code
class ScrShot(object):
def Screenie(self):
file_name = Filename('WFT-ScreenShot-'+str(date)+'.jpg')
base.win.saveScreenshot(file_name)
print ':debug: screenshot taken!'
print ':debug: screenshot saved as ', file_name ,''
instance = ScrShot()
base.accept('f9', instance.Screenie)
and heres the variable used:
###########################################
#time
date = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
###########################################
Plus, something from the log:
:debug: screenshot taken!
:debug: screenshot saved as WFT-ScreenShot-2013-12-24-18-46-04.jpg
:debug: screenshot taken!
:debug: screenshot saved as WFT-ScreenShot-2013-12-24-18-46-04.jpg
:debug: screenshot taken!
:debug: screenshot saved as WFT-ScreenShot-2013-12-24-18-46-04.jpg
Now, any another method to update the date?
EDIT: It did fix the problem, but i also wanted to save in a external folder. Is there a way to do it?
Replace your class with:
It outputs all the same date because you assigned
date
only once. It dosesn't update automatically when you usedate
. You have to callnow()
everytime when you want to get a new date.