Spaces:
Running
Running
zach
commited on
Commit
·
c3aef5f
1
Parent(s):
048c3fc
Fix vote button state management after vote button click
Browse files- src/app.py +19 -4
src/app.py
CHANGED
@@ -233,14 +233,14 @@ def vote(
|
|
233 |
return (
|
234 |
True,
|
235 |
(
|
236 |
-
gr.update(value=selected_label, variant="primary"
|
237 |
if selected_option == constants.OPTION_A_KEY
|
238 |
-
else gr.update(value=other_label, variant="secondary"
|
239 |
),
|
240 |
(
|
241 |
-
gr.update(value=other_label, variant="secondary"
|
242 |
if selected_option == constants.OPTION_A_KEY
|
243 |
-
else gr.update(value=selected_label, variant="primary"
|
244 |
),
|
245 |
gr.update(interactive=True),
|
246 |
)
|
@@ -471,6 +471,13 @@ def build_gradio_interface() -> gr.Blocks:
|
|
471 |
|
472 |
# Vote button click event handlers
|
473 |
vote_button_a.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
fn=vote,
|
475 |
inputs=[
|
476 |
vote_submitted_state,
|
@@ -487,7 +494,15 @@ def build_gradio_interface() -> gr.Blocks:
|
|
487 |
synthesize_speech_button,
|
488 |
],
|
489 |
)
|
|
|
490 |
vote_button_b.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
fn=vote,
|
492 |
inputs=[
|
493 |
vote_submitted_state,
|
|
|
233 |
return (
|
234 |
True,
|
235 |
(
|
236 |
+
gr.update(value=selected_label, variant="primary")
|
237 |
if selected_option == constants.OPTION_A_KEY
|
238 |
+
else gr.update(value=other_label, variant="secondary")
|
239 |
),
|
240 |
(
|
241 |
+
gr.update(value=other_label, variant="secondary")
|
242 |
if selected_option == constants.OPTION_A_KEY
|
243 |
+
else gr.update(value=selected_label, variant="primary")
|
244 |
),
|
245 |
gr.update(interactive=True),
|
246 |
)
|
|
|
471 |
|
472 |
# Vote button click event handlers
|
473 |
vote_button_a.click(
|
474 |
+
fn=lambda: (
|
475 |
+
gr.update(interactive=False),
|
476 |
+
gr.update(interactive=False),
|
477 |
+
),
|
478 |
+
inputs=[],
|
479 |
+
outputs=[vote_button_a, vote_button_b],
|
480 |
+
).then(
|
481 |
fn=vote,
|
482 |
inputs=[
|
483 |
vote_submitted_state,
|
|
|
494 |
synthesize_speech_button,
|
495 |
],
|
496 |
)
|
497 |
+
|
498 |
vote_button_b.click(
|
499 |
+
fn=lambda: (
|
500 |
+
gr.update(interactive=False),
|
501 |
+
gr.update(interactive=False),
|
502 |
+
),
|
503 |
+
inputs=[],
|
504 |
+
outputs=[vote_button_a, vote_button_b],
|
505 |
+
).then(
|
506 |
fn=vote,
|
507 |
inputs=[
|
508 |
vote_submitted_state,
|