Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -250,12 +250,13 @@ css = """
|
|
250 |
.zip-button:hover { background-color: #1e88e5; }
|
251 |
.status-box { border: 1px solid #ddd; background-color: #f9f9f9; padding: 10px; border-radius: 5px; }
|
252 |
.input-group { border: 1px solid #ddd; padding: 15px; border-radius: 5px; background-color: #f0f0f0; }
|
253 |
-
.
|
254 |
-
.image-container { position: relative; width: 150px; height: 150px; overflow: hidden; border-radius: 5px; }
|
255 |
.image-container img { width: 100%; height: 100%; object-fit: cover; }
|
256 |
.overlay { position: absolute; bottom: 5px; right: 5px; background-color: rgba(0, 0, 0, 0.6); padding: 5px; border-radius: 5px; display: flex; align-items: center; gap: 5px; color: white; font-size: 12px; }
|
257 |
.overlay label { margin: 0; color: white; }
|
258 |
.overlay input[type="checkbox"] { margin: 0; }
|
|
|
|
|
259 |
"""
|
260 |
|
261 |
with gr.Blocks(title="Stock Photo Downloader", css=css) as demo:
|
@@ -280,21 +281,23 @@ with gr.Blocks(title="Stock Photo Downloader", css=css) as demo:
|
|
280 |
gr.Markdown("<p style='color: #666;'>Select images to include in your ZIP file.</p>")
|
281 |
image_paths_state = gr.State()
|
282 |
|
283 |
-
# Pre-create all possible image and checkbox components
|
284 |
image_outputs = [gr.Image(label=f"Image {i+1}", show_label=False, visible=False, height=150, width=150) for i in range(TOTAL_IMAGES)]
|
285 |
checkbox_outputs = [gr.Checkbox(label=f"Image {i+1}", value=False, visible=False, scale=0) for i in range(TOTAL_IMAGES)]
|
286 |
-
|
287 |
-
# Dynamic gallery container with
|
288 |
with gr.Column():
|
289 |
-
gallery_rows = [
|
290 |
-
for row_idx
|
291 |
-
with row:
|
292 |
for col_idx in range(IMAGES_PER_ROW):
|
293 |
idx = row_idx * IMAGES_PER_ROW + col_idx
|
294 |
-
with gr.
|
295 |
-
|
296 |
-
|
297 |
-
|
|
|
|
|
298 |
|
299 |
gr.Markdown("### 📦 Create ZIP File")
|
300 |
submit_button = gr.Button("Create ZIP of Selected Images", elem_classes=["zip-button"])
|
@@ -313,7 +316,7 @@ with gr.Blocks(title="Stock Photo Downloader", css=css) as demo:
|
|
313 |
for i, chk in enumerate(checkbox_outs)
|
314 |
]
|
315 |
row_updates = [
|
316 |
-
gr.Row(visible=(row_idx < (num_downloaded + IMAGES_PER_ROW - 1) // IMAGES_PER_ROW)
|
317 |
for row_idx in range(MAX_ROWS)
|
318 |
]
|
319 |
|
|
|
250 |
.zip-button:hover { background-color: #1e88e5; }
|
251 |
.status-box { border: 1px solid #ddd; background-color: #f9f9f9; padding: 10px; border-radius: 5px; }
|
252 |
.input-group { border: 1px solid #ddd; padding: 15px; border-radius: 5px; background-color: #f0f0f0; }
|
253 |
+
.image-container { position: relative; width: 100%; height: 150px; overflow: hidden; border-radius: 5px; }
|
|
|
254 |
.image-container img { width: 100%; height: 100%; object-fit: cover; }
|
255 |
.overlay { position: absolute; bottom: 5px; right: 5px; background-color: rgba(0, 0, 0, 0.6); padding: 5px; border-radius: 5px; display: flex; align-items: center; gap: 5px; color: white; font-size: 12px; }
|
256 |
.overlay label { margin: 0; color: white; }
|
257 |
.overlay input[type="checkbox"] { margin: 0; }
|
258 |
+
.gallery-row { display: flex; flex-wrap: wrap; gap: 10px; }
|
259 |
+
.gallery-column { flex: 1 1 calc(25% - 10px); min-width: 150px; }
|
260 |
"""
|
261 |
|
262 |
with gr.Blocks(title="Stock Photo Downloader", css=css) as demo:
|
|
|
281 |
gr.Markdown("<p style='color: #666;'>Select images to include in your ZIP file.</p>")
|
282 |
image_paths_state = gr.State()
|
283 |
|
284 |
+
# Pre-create all possible image and checkbox components
|
285 |
image_outputs = [gr.Image(label=f"Image {i+1}", show_label=False, visible=False, height=150, width=150) for i in range(TOTAL_IMAGES)]
|
286 |
checkbox_outputs = [gr.Checkbox(label=f"Image {i+1}", value=False, visible=False, scale=0) for i in range(TOTAL_IMAGES)]
|
287 |
+
|
288 |
+
# Dynamic gallery container with rows
|
289 |
with gr.Column():
|
290 |
+
gallery_rows = []
|
291 |
+
for row_idx in range(MAX_ROWS):
|
292 |
+
with gr.Row(elem_classes=["gallery-row"], visible=False) as row:
|
293 |
for col_idx in range(IMAGES_PER_ROW):
|
294 |
idx = row_idx * IMAGES_PER_ROW + col_idx
|
295 |
+
with gr.Column(elem_classes=["gallery-column"]):
|
296 |
+
with gr.Group(elem_classes=["image-container"]):
|
297 |
+
image_outputs[idx]
|
298 |
+
with gr.Row(elem_classes=["overlay"]):
|
299 |
+
checkbox_outputs[idx]
|
300 |
+
gallery_rows.append(row)
|
301 |
|
302 |
gr.Markdown("### 📦 Create ZIP File")
|
303 |
submit_button = gr.Button("Create ZIP of Selected Images", elem_classes=["zip-button"])
|
|
|
316 |
for i, chk in enumerate(checkbox_outs)
|
317 |
]
|
318 |
row_updates = [
|
319 |
+
gr.Row(visible=(row_idx < (num_downloaded + IMAGES_PER_ROW - 1) // IMAGES_PER_ROW))
|
320 |
for row_idx in range(MAX_ROWS)
|
321 |
]
|
322 |
|