Oysiyl commited on
Commit
ff56691
·
1 Parent(s): b03ddfc

Show export buttons only after successful generation, hide on reset

Browse files

- Start both export rows hidden (visible=False)
- Show on successful final yield in generate_standard_qr and generate_artistic_qr
- Keep hidden during progressive generation yields
- Hide when user clicks 'Try Another Example'
- Hide when user selects a gallery example
- Wire export_row_artistic/standard into all relevant .click() outputs lists

Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -1419,16 +1419,17 @@ def generate_standard_qr(
1419
  for image, status in generator:
1420
  final_image = image
1421
  final_status = status
1422
- # Show progressive updates but don't show accordion yet
1423
- yield (image, status, gr.update(), gr.update())
1424
 
1425
- # After all steps complete, show the accordion with JSON
1426
  if final_image is not None:
1427
  yield (
1428
  final_image,
1429
  final_status,
1430
  gr.update(value=settings_json), # Update textbox content
1431
  gr.update(visible=True), # Make accordion visible only at the end
 
1432
  )
1433
 
1434
 
@@ -1581,6 +1582,7 @@ def generate_artistic_qr(
1581
  gr.update(), # Accordion (no change yet)
1582
  gr.update(visible=False), # Hide gallery
1583
  gr.update(visible=False), # Hide show examples button during generation
 
1584
  )
1585
  first_yield = False
1586
  else:
@@ -1591,6 +1593,7 @@ def generate_artistic_qr(
1591
  gr.update(), # Accordion (no change yet)
1592
  gr.update(visible=False), # Keep gallery hidden
1593
  gr.update(visible=False), # Keep button hidden during generation
 
1594
  )
1595
 
1596
  # After all steps complete, show the accordion with JSON and the "Try Another Example" button
@@ -1602,6 +1605,7 @@ def generate_artistic_qr(
1602
  gr.update(visible=True), # Make accordion visible only at the end
1603
  gr.update(visible=False), # Keep gallery hidden
1604
  gr.update(visible=True), # Show "Try Another Example" button
 
1605
  )
1606
 
1607
 
@@ -3781,8 +3785,8 @@ with gr.Blocks(delete_cache=(3600, 3600)) as demo:
3781
  show_copy_button=True,
3782
  )
3783
 
3784
- # Export buttons — generated on demand at click time (cache-sweep safe)
3785
- with gr.Row():
3786
  png_download_artistic = gr.DownloadButton(
3787
  "⬇ PNG",
3788
  variant="primary",
@@ -3866,6 +3870,7 @@ with gr.Blocks(delete_cache=(3600, 3600)) as demo:
3866
  settings_accordion_artistic,
3867
  example_gallery, # Control gallery visibility
3868
  show_examples_btn, # Control button visibility
 
3869
  ],
3870
  )
3871
 
@@ -3941,6 +3946,7 @@ with gr.Blocks(delete_cache=(3600, 3600)) as demo:
3941
  visible=True, selected_index=new_idx
3942
  ), # Show gallery with random selection
3943
  gr.update(visible=False), # Hide this button
 
3944
  # Load the example settings
3945
  example["prompt"],
3946
  example["text_input"],
@@ -3965,6 +3971,7 @@ with gr.Blocks(delete_cache=(3600, 3600)) as demo:
3965
  settings_accordion_artistic,
3966
  example_gallery,
3967
  show_examples_btn,
 
3968
  # Settings outputs
3969
  artistic_prompt_input,
3970
  artistic_text_input,
@@ -4001,6 +4008,7 @@ with gr.Blocks(delete_cache=(3600, 3600)) as demo:
4001
  "Settings loaded! Click 'Generate Artistic QR' to create your QR code", # Show in Status/Errors
4002
  gr.update(visible=False), # Hide settings accordion
4003
  evt.index, # Store the selected example index
 
4004
  )
4005
 
4006
  # Attach the event handler
@@ -4023,6 +4031,7 @@ with gr.Blocks(delete_cache=(3600, 3600)) as demo:
4023
  artistic_error_message, # Show status message
4024
  settings_accordion_artistic, # Reset visibility
4025
  current_example_index, # Store the selected example index
 
4026
  ],
4027
  )
4028
 
@@ -4424,8 +4433,8 @@ with gr.Blocks(delete_cache=(3600, 3600)) as demo:
4424
  show_copy_button=True,
4425
  )
4426
 
4427
- # Export buttons — generated on demand at click time (cache-sweep safe)
4428
- with gr.Row():
4429
  png_download_standard = gr.DownloadButton(
4430
  "⬇ PNG",
4431
  variant="primary",
@@ -4475,6 +4484,7 @@ with gr.Blocks(delete_cache=(3600, 3600)) as demo:
4475
  error_message,
4476
  settings_output_standard,
4477
  settings_accordion_standard,
 
4478
  ],
4479
  show_progress="full",
4480
  )
 
1419
  for image, status in generator:
1420
  final_image = image
1421
  final_status = status
1422
+ # Show progressive updates but don't show accordion or export buttons yet
1423
+ yield (image, status, gr.update(), gr.update(), gr.update(visible=False))
1424
 
1425
+ # After all steps complete, show the accordion with JSON and export buttons
1426
  if final_image is not None:
1427
  yield (
1428
  final_image,
1429
  final_status,
1430
  gr.update(value=settings_json), # Update textbox content
1431
  gr.update(visible=True), # Make accordion visible only at the end
1432
+ gr.update(visible=True), # Show export buttons on success
1433
  )
1434
 
1435
 
 
1582
  gr.update(), # Accordion (no change yet)
1583
  gr.update(visible=False), # Hide gallery
1584
  gr.update(visible=False), # Hide show examples button during generation
1585
+ gr.update(visible=False), # Keep export row hidden during generation
1586
  )
1587
  first_yield = False
1588
  else:
 
1593
  gr.update(), # Accordion (no change yet)
1594
  gr.update(visible=False), # Keep gallery hidden
1595
  gr.update(visible=False), # Keep button hidden during generation
1596
+ gr.update(visible=False), # Keep export row hidden during generation
1597
  )
1598
 
1599
  # After all steps complete, show the accordion with JSON and the "Try Another Example" button
 
1605
  gr.update(visible=True), # Make accordion visible only at the end
1606
  gr.update(visible=False), # Keep gallery hidden
1607
  gr.update(visible=True), # Show "Try Another Example" button
1608
+ gr.update(visible=True), # Show export buttons on success
1609
  )
1610
 
1611
 
 
3785
  show_copy_button=True,
3786
  )
3787
 
3788
+ # Export buttons — hidden until generation succeeds
3789
+ with gr.Row(visible=False) as export_row_artistic:
3790
  png_download_artistic = gr.DownloadButton(
3791
  "⬇ PNG",
3792
  variant="primary",
 
3870
  settings_accordion_artistic,
3871
  example_gallery, # Control gallery visibility
3872
  show_examples_btn, # Control button visibility
3873
+ export_row_artistic, # Control export buttons visibility
3874
  ],
3875
  )
3876
 
 
3946
  visible=True, selected_index=new_idx
3947
  ), # Show gallery with random selection
3948
  gr.update(visible=False), # Hide this button
3949
+ gr.update(visible=False), # Hide export buttons
3950
  # Load the example settings
3951
  example["prompt"],
3952
  example["text_input"],
 
3971
  settings_accordion_artistic,
3972
  example_gallery,
3973
  show_examples_btn,
3974
+ export_row_artistic, # Hide export buttons
3975
  # Settings outputs
3976
  artistic_prompt_input,
3977
  artistic_text_input,
 
4008
  "Settings loaded! Click 'Generate Artistic QR' to create your QR code", # Show in Status/Errors
4009
  gr.update(visible=False), # Hide settings accordion
4010
  evt.index, # Store the selected example index
4011
+ gr.update(visible=False), # Hide export buttons
4012
  )
4013
 
4014
  # Attach the event handler
 
4031
  artistic_error_message, # Show status message
4032
  settings_accordion_artistic, # Reset visibility
4033
  current_example_index, # Store the selected example index
4034
+ export_row_artistic, # Hide export buttons
4035
  ],
4036
  )
4037
 
 
4433
  show_copy_button=True,
4434
  )
4435
 
4436
+ # Export buttons — hidden until generation succeeds
4437
+ with gr.Row(visible=False) as export_row_standard:
4438
  png_download_standard = gr.DownloadButton(
4439
  "⬇ PNG",
4440
  variant="primary",
 
4484
  error_message,
4485
  settings_output_standard,
4486
  settings_accordion_standard,
4487
+ export_row_standard, # Control export buttons visibility
4488
  ],
4489
  show_progress="full",
4490
  )