tagger remembers custom choices
This commit is contained in:
@@ -42,29 +42,27 @@ class Click:
|
||||
|
||||
self.top=Toplevel(self.root)
|
||||
self.top.bind("<Escape>", self._quit)
|
||||
self.tagTexts=['Next']+tags
|
||||
self.tagTexts=tags
|
||||
self.tags=[]
|
||||
self.tags.append(Button(self.top,text="[n] Next", command=self._tag_button("n")))
|
||||
self.root.bind("n", self._tag_key)
|
||||
for t in range(len(self.tagTexts)):
|
||||
return_func=self._tag_button(t)
|
||||
if t==0:
|
||||
self.tags.append(Button(self.top,text="[n] "+self.tagTexts[t], command=return_func))
|
||||
self.root.bind("n", self._tag_key)
|
||||
#self.top.bind("n", self._tag_key)
|
||||
continue
|
||||
if t<10:
|
||||
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.top.bind(str(t), self._tag_key)
|
||||
continue
|
||||
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)+1):
|
||||
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[t+1].bind("<Return>", self._tag_key)
|
||||
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._resize_init()
|
||||
@@ -76,7 +74,8 @@ class Click:
|
||||
|
||||
def _tag_key(self,event):
|
||||
if event.keysym=="n":
|
||||
event.keysym=0
|
||||
self._tag_button("n")()
|
||||
return
|
||||
if event.keysym=="Return":
|
||||
self._tag_button("custom")()
|
||||
return
|
||||
@@ -85,7 +84,7 @@ class Click:
|
||||
|
||||
def _tag_button(self,n):
|
||||
def actual_value(x=n):
|
||||
if x==0:
|
||||
if x=="n":
|
||||
self._next(n)
|
||||
return
|
||||
self._add_tag(x)
|
||||
@@ -126,11 +125,13 @@ class Click:
|
||||
sys.exit(0)
|
||||
|
||||
def _next(self,event):
|
||||
self.root.destroy()
|
||||
self.root.destroy()
|
||||
|
||||
def _add_tag(self,x):
|
||||
if x=="custom":
|
||||
value=self.tags[ len(self.tags)-2 ].get().strip()
|
||||
if value not in self.tagTexts:
|
||||
self.tagTexts.append(value)
|
||||
if value=="":
|
||||
return
|
||||
else:
|
||||
@@ -166,6 +167,9 @@ class Click:
|
||||
conn.text_factory=str
|
||||
db=conn.cursor()
|
||||
self.db=[db,conn]
|
||||
|
||||
def get_tags(self):
|
||||
return self.tagTexts
|
||||
|
||||
|
||||
opt=setup_options()
|
||||
@@ -177,4 +181,4 @@ else:
|
||||
for i,l in enumerate(imagelist):
|
||||
print("%s %d"%( l, len(imagelist)-i))
|
||||
clicker = Click(l,opt.tags,opt.sqlfile)
|
||||
|
||||
#print(clicker.get_tags())
|
||||
|
||||
Reference in New Issue
Block a user