add support for jpeg, less ambigious extension list

This commit is contained in:
= 2022-12-18 07:00:52 +07:00
parent bc51caa42c
commit f18d63f09f
1 changed files with 5 additions and 2 deletions

View File

@ -13,6 +13,8 @@ from tkinter import filedialog
from PIL import Image, ImageTk from PIL import Image, ImageTk
from pathlib import Path from pathlib import Path
IMG_EXT = ["jpg", "jpeg", "png"]
class CaptionedImage(): class CaptionedImage():
def __init__(self, image_path): def __init__(self, image_path):
self.base_path = image_path.parent self.base_path = image_path.parent
@ -67,8 +69,9 @@ class ImageView(tk.Frame):
if self.base_path is None: if self.base_path is None:
return return
self.images.clear() self.images.clear()
for file in self.base_path.glob('*.[jp][pn][gg]'): # jpg or png for ext in IMG_EXT:
self.images.append(CaptionedImage(file)) for file in self.base_path.glob(f'*.{ext}'):
self.images.append(CaptionedImage(file))
self.images.sort() self.images.sort()
self.update_ui() self.update_ui()