Significant commited on
Commit
fe2c725
·
verified ·
1 Parent(s): d2e0a0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -278,13 +278,12 @@ def update_theme_buttons(gender):
278
  updates = []
279
  themes = list(prompts.keys())
280
 
281
- for i, btn in enumerate(theme_buttons):
282
- theme = list(man_prompts.keys())[i]
283
- btn.click(
284
- fn=make_click_fn(theme),
285
- inputs=gender_selector,
286
- outputs=[prompt, prompt_suggestions]
287
- )
288
  return updates
289
 
290
 
@@ -453,7 +452,7 @@ def update_prompt_buttons_visibility(gender):
453
  prompts = man_prompts if gender == "man" else woman_prompts
454
  return [gr.update(value=theme, visible=True) for theme in prompts.keys()]
455
 
456
- # theme_btns = [gr.Button(theme, visible=False) for theme in list(man_prompts.keys())]
457
 
458
  with gr.Blocks(css=css) as demo:
459
  gr.Markdown(logo)
@@ -498,9 +497,9 @@ with gr.Blocks(css=css) as demo:
498
  with gr.Group(visible=False, elem_id="prompt_suggestions_box") as prompt_suggestions:
499
  gr.Markdown("### Suggested Prompts")
500
 
501
- theme_buttons = [gr.Button(theme, visible=False) for theme in man_prompts.keys()]
502
- for theme in list(man_prompts.keys()): # initially load man themes
503
- btn = gr.Button(theme)
504
  theme_buttons.append(btn)
505
  # theme_buttons.append(gr.Button(theme))
506
  # prompt_buttons = []
 
278
  updates = []
279
  themes = list(prompts.keys())
280
 
281
+ for i, theme in enumerate(themes):
282
+ if i < len(theme_buttons):
283
+ updates.append(gr.update(value=theme, visible=True))
284
+ # hide extra buttons if any
285
+ for j in range(len(themes), len(theme_buttons)):
286
+ updates.append(gr.update(visible=False))
 
287
  return updates
288
 
289
 
 
452
  prompts = man_prompts if gender == "man" else woman_prompts
453
  return [gr.update(value=theme, visible=True) for theme in prompts.keys()]
454
 
455
+ theme_btns = []
456
 
457
  with gr.Blocks(css=css) as demo:
458
  gr.Markdown(logo)
 
497
  with gr.Group(visible=False, elem_id="prompt_suggestions_box") as prompt_suggestions:
498
  gr.Markdown("### Suggested Prompts")
499
 
500
+ # theme_buttons = [gr.Button(theme, visible=False) for theme in man_prompts.keys()]
501
+ for theme in man_prompts.keys(): # initially load man themes
502
+ btn = gr.Button(theme, visible=False)
503
  theme_buttons.append(btn)
504
  # theme_buttons.append(gr.Button(theme))
505
  # prompt_buttons = []