diff options
author | Leonard Kugis <leonard@kug.is> | 2023-03-21 18:38:13 +0100 |
---|---|---|
committer | Leonard Kugis <leonard@kug.is> | 2023-03-21 18:38:13 +0100 |
commit | 1e8b7d36a6175d6b59fe868eb5aede6bd30ae9ac (patch) | |
tree | b40ef3c8c321d27a8231fd2b14b99b678e93fae1 /gui.py | |
parent | 91ea248b5f79bfa600bf36ec3d5fe08fa507c5db (diff) |
CLI, GUI
Implemented better CLI compatibility.
Implemented generic GUI for all file types.
Diffstat (limited to 'gui.py')
-rw-r--r-- | gui.py | 45 |
1 files changed, 32 insertions, 13 deletions
@@ -11,36 +11,55 @@ class GuiMain(object): self.__args = args self.__base = StringVar(self.__master, value=args["base"]) self.__predict_images = BooleanVar(self.__master, value=args["predict_images"]) - self.__gui_images = BooleanVar(self.__master, value=args["gui_images"]) - self.__gui_audio = BooleanVar(self.__master, value=args["gui_audio"]) - self.__gui_video = BooleanVar(self.__master, value=args["gui_video"]) - self.__open_all = BooleanVar(self.__master, value=args["open_all"]) + self.__gui_tag = BooleanVar(self.__master, value=args["gui_tag"]) + self.__open_system = BooleanVar(self.__master, value=args["open_system"]) Label(self.__master, text="Base directory for walking:").grid(row=0, column=0) Entry(self.__master, textvariable=self.__base).grid(row=0, column=1) Button(self.__master, text="Browse", command=lambda: self.__browse(base)).grid(row=0, column=3) Checkbutton(self.__master, text="Use prediction for image tagging", variable=self.__predict_images).grid(row=1, sticky=W) - Checkbutton(self.__master, text="Show GUI for image tagging", variable=self.__gui_images).grid(row=2, sticky=W) - Checkbutton(self.__master, text="Show GUI for audio tagging", variable=self.__gui_audio).grid(row=3, sticky=W) - Checkbutton(self.__master, text="Show GUI for video tagging", variable=self.__gui_video).grid(row=4, sticky=W) - Checkbutton(self.__master, text="Open all files with system default", variable=self.__open_all).grid(row=5, sticky=W) - Button(self.__master, text="Start", command=self.__master.destroy).grid(row=6) + Checkbutton(self.__master, text="Show GUI for tagging", variable=self.__gui_tag).grid(row=2, sticky=W) + Checkbutton(self.__master, text="Open all files with system default", variable=self.__open_system).grid(row=3, sticky=W) + Button(self.__master, text="Start", command=self.__master.destroy).grid(row=4) def loop(self): self.__master.mainloop() self.__args["base"] = self.__base.get() self.__args["predict_images"] = self.__predict_images.get() - self.__args["gui_images"] = self.__gui_images.get() - self.__args["gui_audio"] = self.__gui_audio.get() - self.__args["gui_video"] = self.__gui_video.get() - self.__args["open_all"] = self.__open_all.get() + self.__args["gui_tag"] = self.__gui_tag.get() + self.__args["open_system"] = self.__open_system.get() return self.__args def __browse(self, folder_path): filename = filedialog.askdirectory() folder_path.set(filename) +class GuiTag(object): + RETURN_NEXT = 0 + RETURN_ABORT = 1 + + def __init__(self, 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) + + def loop(self): + self.__master.mainloop() + return (self.__ret, self.__tags.get().split(",")) + + def __handle_next(self): + self.__ret = self.RETURN_NEXT + self.__master.destroy() + + def __handle_abort(self): + self.__ret = self.RETURN_ABORT + self.__master.destroy() + class GuiImage(object): RETURN_NEXT = 0, RETURN_ROTATE_90_COUNTERCLOCKWISE = 1, |