Skip to content

Commit

Permalink
fix img browser
Browse files Browse the repository at this point in the history
Signed-off-by: ふぁ <[email protected]>
  • Loading branch information
fa0311 committed May 14, 2023
1 parent c8650b3 commit 3008f40
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions modules/tabs/images_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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],
)

0 comments on commit 3008f40

Please sign in to comment.