Significant commited on
Commit
adb41cb
·
verified ·
1 Parent(s): 1a4ffa5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -384,11 +384,16 @@ with gr.Blocks(css=css) as demo:
384
 
385
  with gr.Box(visible=False, elem_id="prompt_suggestions_box") as prompt_suggestions:
386
  gr.Markdown("### 🎯 Suggested Prompts")
387
- prompt_buttons = [
388
- gr.Button("A photo of a smiling woman img in a sunny park"),
389
- gr.Button("A portrait of a man img in cinematic lighting"),
390
- gr.Button("A studio photo of a woman img wearing glasses")
 
391
  ]
 
 
 
 
392
  close_btn = gr.Button("❌ Close", elem_id="close_prompt_box")
393
 
394
  style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
@@ -527,12 +532,11 @@ with gr.Blocks(css=css) as demo:
527
  )
528
 
529
  # When user clicks on a suggestion, fill the prompt textbox and close popup
530
- for btn in prompt_buttons:
531
- btn.click(
532
- lambda text: (gr.update(value=text), gr.update(visible=False)),
533
  inputs=None,
534
- outputs=[prompt, prompt_suggestions],
535
- _js=f"() => '{btn.value}'" # injects the button text
536
  )
537
 
538
 
 
384
 
385
  with gr.Box(visible=False, elem_id="prompt_suggestions_box") as prompt_suggestions:
386
  gr.Markdown("### 🎯 Suggested Prompts")
387
+ # ✅ Suggestions list
388
+ suggestions = [
389
+ "A photo of a smiling woman img in a sunny park",
390
+ "A portrait of a man img in cinematic lighting",
391
+ "A studio photo of a woman img wearing glasses"
392
  ]
393
+ prompt_buttons = []
394
+ for s in suggestions:
395
+ b = gr.Button(s)
396
+ prompt_buttons.append((b, s))
397
  close_btn = gr.Button("❌ Close", elem_id="close_prompt_box")
398
 
399
  style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
 
532
  )
533
 
534
  # When user clicks on a suggestion, fill the prompt textbox and close popup
535
+ for b, text in prompt_buttons:
536
+ b.click(
537
+ lambda t=text: (gr.update(value=t), gr.update(visible=False)),
538
  inputs=None,
539
+ outputs=[prompt, prompt_suggestions]
 
540
  )
541
 
542