Spaces:
Sleeping
Sleeping
Fix batch download button - use Button+File instead of DownloadButton
Browse files- ui/callbacks.py +4 -4
- ui/layout.py +6 -1
ui/callbacks.py
CHANGED
|
@@ -1604,12 +1604,12 @@ def handle_batch_download(output_path_str: str):
|
|
| 1604 |
import tempfile
|
| 1605 |
|
| 1606 |
if not output_path_str:
|
| 1607 |
-
return
|
| 1608 |
|
| 1609 |
from pathlib import Path
|
| 1610 |
output_path = Path(output_path_str)
|
| 1611 |
if not output_path.exists() or not output_path.is_dir():
|
| 1612 |
-
return
|
| 1613 |
|
| 1614 |
# Create a temporary ZIP file
|
| 1615 |
temp_zip = tempfile.NamedTemporaryFile(
|
|
@@ -1627,7 +1627,7 @@ def handle_batch_download(output_path_str: str):
|
|
| 1627 |
arcname = file.relative_to(output_path)
|
| 1628 |
zipf.write(file, arcname)
|
| 1629 |
|
| 1630 |
-
return temp_zip.name
|
| 1631 |
except Exception as e:
|
| 1632 |
print(f"Error creating ZIP file: {e}")
|
| 1633 |
-
return
|
|
|
|
| 1604 |
import tempfile
|
| 1605 |
|
| 1606 |
if not output_path_str:
|
| 1607 |
+
return gr.update(visible=False)
|
| 1608 |
|
| 1609 |
from pathlib import Path
|
| 1610 |
output_path = Path(output_path_str)
|
| 1611 |
if not output_path.exists() or not output_path.is_dir():
|
| 1612 |
+
return gr.update(visible=False)
|
| 1613 |
|
| 1614 |
# Create a temporary ZIP file
|
| 1615 |
temp_zip = tempfile.NamedTemporaryFile(
|
|
|
|
| 1627 |
arcname = file.relative_to(output_path)
|
| 1628 |
zipf.write(file, arcname)
|
| 1629 |
|
| 1630 |
+
return gr.update(value=temp_zip.name, visible=True)
|
| 1631 |
except Exception as e:
|
| 1632 |
print(f"Error creating ZIP file: {e}")
|
| 1633 |
+
return gr.update(visible=False)
|
ui/layout.py
CHANGED
|
@@ -368,11 +368,15 @@ def create_layout(
|
|
| 368 |
"Cancel", variant="stop", visible=False
|
| 369 |
)
|
| 370 |
with gr.Row():
|
| 371 |
-
batch_download_button = gr.
|
| 372 |
"Download All Images as ZIP",
|
| 373 |
variant="secondary",
|
| 374 |
visible=False,
|
| 375 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
|
| 377 |
with gr.TabItem("Config", elem_id="settings-tab-container"):
|
| 378 |
config_initial_provider = initial_provider
|
|
@@ -2378,6 +2382,7 @@ def create_layout(
|
|
| 2378 |
batch_download_button.click(
|
| 2379 |
fn=callbacks.handle_batch_download,
|
| 2380 |
inputs=batch_output_path_state,
|
|
|
|
| 2381 |
)
|
| 2382 |
|
| 2383 |
app.load(
|
|
|
|
| 368 |
"Cancel", variant="stop", visible=False
|
| 369 |
)
|
| 370 |
with gr.Row():
|
| 371 |
+
batch_download_button = gr.Button(
|
| 372 |
"Download All Images as ZIP",
|
| 373 |
variant="secondary",
|
| 374 |
visible=False,
|
| 375 |
)
|
| 376 |
+
batch_download_file = gr.File(
|
| 377 |
+
label="Download ZIP",
|
| 378 |
+
visible=False,
|
| 379 |
+
)
|
| 380 |
|
| 381 |
with gr.TabItem("Config", elem_id="settings-tab-container"):
|
| 382 |
config_initial_provider = initial_provider
|
|
|
|
| 2382 |
batch_download_button.click(
|
| 2383 |
fn=callbacks.handle_batch_download,
|
| 2384 |
inputs=batch_output_path_state,
|
| 2385 |
+
outputs=[batch_download_file],
|
| 2386 |
)
|
| 2387 |
|
| 2388 |
app.load(
|