itsalissonsilva commited on
Commit
2c853f0
·
verified ·
1 Parent(s): 658dc42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -34,14 +34,10 @@ def update_scenario(choice_index):
34
  with gr.Blocks() as app:
35
  with gr.Row():
36
  story_display = gr.Textbox(value=scenario, show_label=False, lines=7)
37
- choices_buttons = [gr.Button(choice) for choice in choices]
38
 
39
- def handle_choice(choice_index):
40
- new_story = update_scenario(choice_index)
41
- story_display.update(value=new_story)
42
- return gr.update()
43
-
44
- for i, button in enumerate(choices_buttons):
45
- button.click(fn=handle_choice, inputs=[i], outputs=story_display)
46
 
47
  app.launch()
 
34
  with gr.Blocks() as app:
35
  with gr.Row():
36
  story_display = gr.Textbox(value=scenario, show_label=False, lines=7)
 
37
 
38
+ with gr.Row():
39
+ for i, choice in enumerate(choices):
40
+ button = gr.Button(choice)
41
+ button.click(fn=update_scenario, data=i, outputs=story_display)
 
 
 
42
 
43
  app.launch()