From 3008f40cc30f9cce7bc639a0b58b90e8041a1ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Mon, 15 May 2023 03:53:42 +0900 Subject: [PATCH] fix img browser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- modules/tabs/images_browser.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/modules/tabs/images_browser.py b/modules/tabs/images_browser.py index 2aacfc4d..64096124 100644 --- a/modules/tabs/images_browser.py +++ b/modules/tabs/images_browser.py @@ -59,14 +59,12 @@ def change_page(page: float, index: int, tab: str, flag: bool): elif page > (img_len - 1) // max_img_len + 1: page = (img_len - 1) // max_img_len + 1 - if flag: - g_img = [f for f in imgs if os.path.isfile(f)] - g_img = sorted(g_img, key=os.path.getmtime) - g_img = g_img[(page - 1) * max_img_len : page * max_img_len] + g_img = [f for f in imgs if os.path.isfile(f)] + g_img = sorted(g_img, key=os.path.getmtime) + g_img = g_img[(page - 1) * max_img_len : page * max_img_len] - select_img = (page - 1) * max_img_len + index - if index >= 0 and select_img < len(imgs): - imgs = imgs[select_img] + if index >= 0 and index < len(g_img): + imgs = g_img[index] param: dict = Image.open(imgs).text parameters = param.pop("parameters") try: @@ -86,10 +84,7 @@ def change_page(page: float, index: int, tab: str, flag: bool): gallery.update(g_img), ) else: - return ( - page_box.update(page), - info.update(value), - ) + return info.update(value) tab.select(lambda x: page_box.update(-1), page_box, page_box) prev_btn.click(lambda x: page_box.update(x - 1), page_box, page_box) @@ -104,5 +99,5 @@ def change_page(page: float, index: int, tab: str, flag: bool): fn=lambda x, y, z: change_page(x, y, z, False), _js=f"(x,y,z)=>[x,selectedGalleryButton('{id}'),selectedTab('{tab_id}')]", inputs=[page_box, info, gallery], - outputs=[page_box, info], + outputs=[info], )