Merge pull request #16 from mstevenson/main
Image caption GUI app fixes
This commit is contained in:
commit
99eb7dedc8
|
@ -35,7 +35,7 @@ class CaptionedImage():
|
||||||
|
|
||||||
# sort
|
# sort
|
||||||
def __lt__(self, other):
|
def __lt__(self, other):
|
||||||
return self.path < other.path
|
return str(self.path).lower() < str(other.path).lower()
|
||||||
|
|
||||||
class ImageView(tk.Frame):
|
class ImageView(tk.Frame):
|
||||||
|
|
||||||
|
@ -60,7 +60,10 @@ class ImageView(tk.Frame):
|
||||||
self.caption_frame.pack(fill=tk.Y, side=tk.RIGHT)
|
self.caption_frame.pack(fill=tk.Y, side=tk.RIGHT)
|
||||||
|
|
||||||
def open_folder(self):
|
def open_folder(self):
|
||||||
self.base_path = Path(filedialog.askdirectory())
|
dir = filedialog.askdirectory()
|
||||||
|
if not dir:
|
||||||
|
return
|
||||||
|
self.base_path = Path(dir)
|
||||||
if self.base_path is None:
|
if self.base_path is None:
|
||||||
return
|
return
|
||||||
self.images.clear()
|
self.images.clear()
|
||||||
|
@ -103,8 +106,8 @@ class ImageView(tk.Frame):
|
||||||
caption_path = img.caption_path()
|
caption_path = img.caption_path()
|
||||||
if caption_path.exists():
|
if caption_path.exists():
|
||||||
caption_path.rename(trash_path / caption_path.name)
|
caption_path.rename(trash_path / caption_path.name)
|
||||||
|
|
||||||
del self.images[self.index]
|
del self.images[self.index]
|
||||||
|
self.set_index(self.index)
|
||||||
self.update_ui()
|
self.update_ui()
|
||||||
|
|
||||||
def update_ui(self):
|
def update_ui(self):
|
||||||
|
@ -116,7 +119,7 @@ class ImageView(tk.Frame):
|
||||||
img = self.images[self.index]
|
img = self.images[self.index]
|
||||||
# filename
|
# filename
|
||||||
title = self.images[self.index].path.name if len(self.images) > 0 else ''
|
title = self.images[self.index].path.name if len(self.images) > 0 else ''
|
||||||
self.root.title(title)
|
self.root.title(title + f' ({self.index+1}/{len(self.images)})')
|
||||||
# caption
|
# caption
|
||||||
self.caption_field.delete(1.0, tk.END)
|
self.caption_field.delete(1.0, tk.END)
|
||||||
self.caption_field.insert(tk.END, img.read_caption())
|
self.caption_field.insert(tk.END, img.read_caption())
|
||||||
|
|
Loading…
Reference in New Issue