tagger custom value
This commit is contained in:
@@ -49,16 +49,22 @@ class Click:
|
|||||||
if t==0:
|
if t==0:
|
||||||
self.tags.append(Button(self.top,text="[n] "+self.tagTexts[t], command=return_func))
|
self.tags.append(Button(self.top,text="[n] "+self.tagTexts[t], command=return_func))
|
||||||
self.root.bind("n", self._tag_key)
|
self.root.bind("n", self._tag_key)
|
||||||
self.top.bind("n", self._tag_key)
|
#self.top.bind("n", self._tag_key)
|
||||||
continue
|
continue
|
||||||
if t<10:
|
if t<10:
|
||||||
self.tags.append(Button(self.top,text="[%d] %s"%(t,self.tagTexts[t]), command=return_func))
|
self.tags.append(Button(self.top,text="[%d] %s"%(t,self.tagTexts[t]), command=return_func))
|
||||||
self.root.bind(str(t), self._tag_key)
|
self.root.bind(str(t), self._tag_key)
|
||||||
self.top.bind(str(t), self._tag_key)
|
#self.top.bind(str(t), self._tag_key)
|
||||||
continue
|
continue
|
||||||
self.tags.append(Button(self.top,text=self.tagTexts[t], command=return_func))
|
self.tags.append(Button(self.top,text=self.tagTexts[t], command=return_func))
|
||||||
for t in range(len(self.tagTexts)):
|
for t in range(len(self.tagTexts)):
|
||||||
self.tags[t].pack(fill="both", side="top")
|
self.tags[t].pack(fill="both", side="top")
|
||||||
|
# custom tag
|
||||||
|
self.tags.append(Entry(self.top))
|
||||||
|
self.tags[t+1].pack(fill="both", side="top")
|
||||||
|
self.tags.append(Button(self.top, text="Custom", command=self._tag_button("custom")))
|
||||||
|
self.tags[t+2].pack(fill="both", side="top")
|
||||||
|
self.tags[t+1].bind("<Return>", self._tag_key)
|
||||||
self.top.geometry("220x%d+0+0"%(self.root.winfo_screenheight()-150,))
|
self.top.geometry("220x%d+0+0"%(self.root.winfo_screenheight()-150,))
|
||||||
|
|
||||||
self._resize_init()
|
self._resize_init()
|
||||||
@@ -71,6 +77,9 @@ class Click:
|
|||||||
def _tag_key(self,event):
|
def _tag_key(self,event):
|
||||||
if event.keysym=="n":
|
if event.keysym=="n":
|
||||||
event.keysym=0
|
event.keysym=0
|
||||||
|
if event.keysym=="Return":
|
||||||
|
self._tag_button("custom")()
|
||||||
|
return
|
||||||
thisfunc=self._tag_button(int(event.keysym))
|
thisfunc=self._tag_button(int(event.keysym))
|
||||||
thisfunc()
|
thisfunc()
|
||||||
|
|
||||||
@@ -120,15 +129,21 @@ class Click:
|
|||||||
self.root.destroy()
|
self.root.destroy()
|
||||||
|
|
||||||
def _add_tag(self,x):
|
def _add_tag(self,x):
|
||||||
|
if x=="custom":
|
||||||
|
value=self.tags[ len(self.tags)-2 ].get().strip()
|
||||||
|
if value=="":
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
value=self.tagTexts[x]
|
||||||
self.db[0].execute("SELECT hash FROM list WHERE file = ?",( os.path.realpath( self.image_name), ))
|
self.db[0].execute("SELECT hash FROM list WHERE file = ?",( os.path.realpath( self.image_name), ))
|
||||||
hashes=self.db[0].fetchall()
|
hashes=self.db[0].fetchall()
|
||||||
if len(hashes)==0:
|
if len(hashes)==0:
|
||||||
print("Image %s not in database!" % (self.image_name) )
|
print("Image %s not in database!" % (self.image_name) )
|
||||||
self._next(None)
|
self._next(None)
|
||||||
return
|
return
|
||||||
self.db[0].execute("INSERT INTO tags (hash,tag) VALUES (?,?)",( hashes[0][0], self.tagTexts[x] ))
|
self.db[0].execute("INSERT INTO tags (hash,tag) VALUES (?,?)",( hashes[0][0],value ))
|
||||||
self.db[1].commit()
|
self.db[1].commit()
|
||||||
print("Added %s:%s"%(self.image_name,self.tagTexts[x]))
|
print("Added %s:%s"%(self.image_name,value))
|
||||||
return
|
return
|
||||||
|
|
||||||
def _print_tags(self):
|
def _print_tags(self):
|
||||||
@@ -157,7 +172,7 @@ opt=setup_options()
|
|||||||
if os.path.isfile(opt.path):
|
if os.path.isfile(opt.path):
|
||||||
imagelist=[opt.path]
|
imagelist=[opt.path]
|
||||||
else:
|
else:
|
||||||
imagelist=sorted([f for f in os.listdir(opt.path) if IMGMATCH.match(f)])
|
imagelist=sorted([os.path.join(opt.path,f) for f in os.listdir(opt.path) if IMGMATCH.match(f)])
|
||||||
|
|
||||||
for i,l in enumerate(imagelist):
|
for i,l in enumerate(imagelist):
|
||||||
print("%s %d"%( l, len(imagelist)-i))
|
print("%s %d"%( l, len(imagelist)-i))
|
||||||
|
|||||||
Reference in New Issue
Block a user