-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgui_imageops.py
66 lines (53 loc) · 2.46 KB
/
gui_imageops.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
path = '/Users/nayana/projects/flask1/ODLC_GUI/static/images'
path1 = '/Users/nayana/projects/flask1/ODLC_GUI/static/images_moved/'
mainimg = '/Users/nayana/projects/flask1/ODLC_GUI/static/images/MainImage.jpg'
class ImageVals:
def __init__(self,imageArray,imageIndex):
self.imageIndex = 0;
self.imageArray = []
def val_set(self,imageArray,imageIndex):
self.imageIndex = imageIndex
self.imageArray = imageArray
def getimg(self,imageArray,imageIndex):
if mainimg not in self.imageArray:
self.imageArray.append(mainimg)
for subdir, dirs, files in os.walk(path):
for file in files:
filepath = os.path.join(subdir, file)
if filepath.endswith('.jpg') or filepath.endswith('.JPG'):
if filepath not in self.imageArray:
self.imageArray.append(filepath)
#print(imageArray)
#return self.imageArray,self.imageIndex;
return None;
def previousimg(self,imageArray,imageIndex,myImage):
if (self.imageIndex!=0):
self.imageIndex=self.imageIndex-1
myImage.setAttribute('src','images/'+self.imageArray[self.imageIndex])
#myImage.src = (self.imageArray[self.imageIndex])
#return self.imageArray,self.imageIndex;
return None;
def nextimg(self,imageArray,imageIndex,myImage):
if (self.imageIndex!=len(self.imageArray)-1):
self.imageIndex += 1
#print("myImage.src",myImage.src)
#myImage.src = (self.imageArray[self.imageIndex])
myImage.setAttribute('src','images/'+self.imageArray[self.imageIndex])
#print("Index",self.imageIndex)
#return self.imageArray,self.imageIndex;
return None;
def deleteimg(self,imageArray,imageIndex):
#self.imageIndex = self.imageIndex-1
os.unlink(self.imageArray[self.imageIndex])
self.imageIndex+=2
#return self.imageArray,self.imageIndex;
return None;
def moveimg(self,imageArray,imageIndex):
#self.imageIndex = self.imageIndex-1
os.rename(self.imageArray[self.imageIndex], path1+'img'+str(imageIndex)+'.jpg')
self.imageIndex+=2
#return self.imageArray,self.imageIndex;
return None;
def image_src(self,imageArray,imageIndex):
return self.imageArray[self.imageIndex];