aboutsummaryrefslogtreecommitdiff
path: root/gui.py
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2023-03-21 19:20:48 +0100
committerLeonard Kugis <leonard@kug.is>2023-03-21 19:20:48 +0100
commit638f4877ce4f2d65d7a190d6590496d091f79bce (patch)
tree26eecf68857da2e3c6ca83642e1306ecc48317c2 /gui.py
parent157832d85788d15a61e885164ef37ab0ee40b048 (diff)
Implemented index handling
Diffstat (limited to 'gui.py')
-rw-r--r--gui.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/gui.py b/gui.py
index 6b6a4a2..c5920d2 100644
--- a/gui.py
+++ b/gui.py
@@ -14,6 +14,7 @@ class GuiMain(object):
self.__predict_images_top = StringVar(self.__master, value=str(args["predict_images_top"]))
self.__gui_tag = BooleanVar(self.__master, value=args["gui_tag"])
self.__open_system = BooleanVar(self.__master, value=args["open_system"])
+ self.__index = StringVar(self.__master, value=str(args["index"]))
validate_number = (self.__master.register(self.__validate_number))
@@ -25,7 +26,9 @@ class GuiMain(object):
Entry(self.__master, textvariable=self.__predict_images_top, validate='all', validatecommand=(validate_number, '%P')).grid(row=2, column=1, columnspan=1)
Checkbutton(self.__master, text="Show GUI for tagging", variable=self.__gui_tag).grid(row=3, column=0, columnspan=4, sticky=W)
Checkbutton(self.__master, text="Open all files with system default", variable=self.__open_system).grid(row=4, column=0, columnspan=4, sticky=W)
- Button(self.__master, text="Start", command=self.__master.destroy).grid(row=5, column=0, columnspan=4)
+ Label(self.__master, text="Start at index:").grid(row=5, column=0)
+ Entry(self.__master, textvariable=self.__index, validate='all', validatecommand=(validate_number, '%P')).grid(row=5, column=1, columnspan=1)
+ Button(self.__master, text="Start", command=self.__master.destroy).grid(row=6, column=0, columnspan=4)
def loop(self):
self.__master.mainloop()
@@ -35,6 +38,7 @@ class GuiMain(object):
self.__args["predict_images_top"] = int(self.__predict_images_top.get())
self.__args["gui_tag"] = self.__gui_tag.get()
self.__args["open_system"] = self.__open_system.get()
+ self.__args["index"] = int(self.__index.get())
return self.__args
def __browse(self):
@@ -51,14 +55,15 @@ class GuiTag(object):
RETURN_NEXT = 0
RETURN_ABORT = 1
- def __init__(self, file, tags):
+ def __init__(self, index, file, tags):
self.__ret = self.RETURN_NEXT
self.__master = Tk()
self.__tags = StringVar(self.__master, value=','.join(tags))
- Label(self.__master, text="File: {}".format(file)).grid(row=0, column=0, columnspan=2)
- Entry(self.__master, textvariable=self.__tags).grid(row=1, column=0, columnspan=2, sticky="we")
- Button(self.__master, text="Next", command=self.__handle_next).grid(row=2, column=0)
- Button(self.__master, text="Abort", command=self.__handle_abort).grid(row=2, column=1)
+ Label(self.__master, text="Index: {}".format(index)).grid(row=0, column=0, columnspan=2)
+ Label(self.__master, text="File: {}".format(file)).grid(row=1, column=0, columnspan=2)
+ Entry(self.__master, textvariable=self.__tags).grid(row=2, column=0, columnspan=2, sticky="we")
+ Button(self.__master, text="Next", command=self.__handle_next).grid(row=3, column=0)
+ Button(self.__master, text="Abort", command=self.__handle_abort).grid(row=3, column=1)
def loop(self):
self.__master.mainloop()
@@ -78,19 +83,21 @@ class GuiImage(object):
RETURN_ROTATE_90_CLOCKWISE = 2,
RETURN_ABORT = 3
- def __init__(self, img, tags):
+ def __init__(self, index, file, img, tags):
self.__ret = self.RETURN_NEXT
self.__master = Tk()
self.__tags = StringVar(self.__master, value=','.join(tags))
self.__image_pil = Image.fromarray(img)
self.__image = ImageTk.PhotoImage(image=self.__image_pil)
+ Label(self.__master, text="Index: {}".format(index)).grid(row=0, column=0, columnspan=4)
+ Label(self.__master, text="File: {}".format(file)).grid(row=1, column=0, columnspan=4)
self.__label = Label(self.__master, width=800, height=800, image=self.__image)
- self.__label.grid(row=0, column=0, columnspan=4)
- Entry(self.__master, textvariable=self.__tags).grid(row=1, column=0, columnspan=4, sticky="we")
- Button(self.__master, text="↺", command=self.__handle_rotate_90_counterclockwise).grid(row=2, column=0)
- Button(self.__master, text="↻", command=self.__handle_rotate_90_clockwise).grid(row=2, column=1)
- Button(self.__master, text="Next", command=self.__handle_next).grid(row=2, column=2)
- Button(self.__master, text="Abort", command=self.__handle_abort).grid(row=2, column=3)
+ self.__label.grid(row=2, column=0, columnspan=4)
+ Entry(self.__master, textvariable=self.__tags).grid(row=3, column=0, columnspan=4, sticky="we")
+ Button(self.__master, text="↺", command=self.__handle_rotate_90_counterclockwise).grid(row=4, column=0)
+ Button(self.__master, text="↻", command=self.__handle_rotate_90_clockwise).grid(row=4, column=1)
+ Button(self.__master, text="Next", command=self.__handle_next).grid(row=4, column=2)
+ Button(self.__master, text="Abort", command=self.__handle_abort).grid(row=4, column=3)
def loop(self):
self.__master.mainloop()