| 1234567891011121314151617181920212223242526 |
- from glob import glob
- import os
- class Slides():
- def __init__(self,path):
- if os.path.isdir(path) != True:
- print("PATH is not a dir")
- self.data = "{'type'='diapo', 'value'='%s', 'number'='%d', 'total'='%d'}"
- self.files=sorted(glob("%s/*.png" % path), key=self.key_func)
- for f in range(0,len(self.files)):
- self.files[f] = os.path.abspath(self.files[f])
- self.cur_diapo=0
- def key_func(self,x):
- return int(os.path.split(x)[-1].rsplit('.', 1)[0])
- def cur(self):
- return ( self.data % (self.files[self.cur_diapo], self.cur_diapo+1, len(self.files)))
- def prev(self):
- self.cur_diapo=max(self.cur_diapo-1, 0)
- return self.cur()
- def next(self):
- self.cur_diapo=min(self.cur_diapo+1, len(self.files)-1)
- return self.cur()
|