added image for empty gallery

This commit is contained in:
Aedh Carrick 2022-12-06 11:23:59 -06:00
parent fd7af4288d
commit 0440929dcd
4 changed files with 29 additions and 4 deletions

3
.gitignore vendored
View File

@ -67,7 +67,8 @@ condaenv.*.requirements.txt
/flagged/*
/gfpgan/*
/models/*
/webui/flet/assets/uploads/*
/webui/flet/assets/uploads/
/webui/flet/assets/outputs/
z_version_env.tmp
scripts/bridgeData.py

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -100,6 +100,8 @@ def get_gallery_images(gallery_name):
files = []
if os.path.exists(path_to_gallery):
files = os.listdir(path_to_gallery)
else:
return None
for f in files:
if f.endswith(('.jpg','.jpeg','.png')):
path_to_file = os.path.join('/uploads',f)

View File

@ -128,7 +128,18 @@ def main(page: ft.Page):
def get_gallery_images(gallery_name):
return flet_utils.get_gallery_images(gallery_name)
def refresh_gallery_images(gallery_name):
def refresh_gallery(gallery_name):
index = None
if gallery_name == 'uploads':
index = 0
elif gallery_name == 'outputs':
index = 1
else:
page.message(f'{gallery_name} gallery not found.', 1)
return None
gallery_window.content.content.tabs[index].content = get_gallery_display(gallery_name)
def get_gallery_display(gallery_name):
gallery_display = ft.Stack(
[
ft.Row(
@ -165,6 +176,16 @@ def main(page: ft.Page):
],
)
gallery = get_gallery_images(gallery_name)
if len(gallery) < 1:
gallery_display.controls[0].controls.append(
ft.Image(
src = '/images/chickens.jpg',
tooltip = 'Nothing here but us chickens!',
gapless_playback = True,
)
)
return gallery_display
for i in range(len(gallery)):
image = gallery[i]
image_name = list(image.keys())[0]
@ -192,11 +213,11 @@ def main(page: ft.Page):
tabs = [
ft.Tab(
text = "Uploads",
content = refresh_gallery_images('uploads'),
content = get_gallery_display('uploads'),
),
ft.Tab(
text = "Outputs",
content = refresh_gallery_images('outputs'),
content = get_gallery_display('outputs'),
),
],
),
@ -243,6 +264,7 @@ def main(page: ft.Page):
page.message('File upload(s) complete.')
layer_manager.add_images_as_layers(file_picker.images)
file_picker.images.clear()
refresh_gallery('uploads')
def get_image_from_uploads(name):
return flet_utils.get_image_from_uploads(name)