Peng Shiya commited on
Commit
ffc48b8
1 Parent(s): c4af616

feature: update feedback submit

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -61,14 +61,12 @@ with block:
61
  with gr.Row():
62
  upvote_button = gr.Button('Upvote')
63
  downvote_button = gr.Button('Downvote')
64
- feedback_textbox = gr.Textbox(lines=3, show_label=False)
65
- feedback_submit_button = gr.Button('Submit')
66
  # components
67
  components = {
68
  point_coords, point_labels, raw_image, masks, cutout_idx,
69
- feedback, upvote_button, downvote_button, feedback_textbox, feedback_submit_button,
70
  input_image, point_label_radio, reset_btn, run_btn, masks_annotated_image}
71
-
72
  # event - init coords
73
  def on_reset_btn_click(raw_image):
74
  return raw_image, point_coords_empty(), point_labels_empty(), None, []
@@ -129,11 +127,11 @@ with block:
129
  masks_annotated_image.select(on_masks_annotated_image_select, components, [cutout_idx, cutout_galary, feedback], queue=False)
130
 
131
  # event - feedback
132
- def on_feedback_submit_button_click(inputs):
133
  inputs[feedback].save_feedback(feedback_str=inputs[feedback_textbox])
134
  gr.Info('Thanks for your feedback')
135
  return inputs[feedback], None
136
- feedback_submit_button.click(on_feedback_submit_button_click, {feedback, feedback_textbox}, [feedback, feedback_textbox], queue=False)
137
  def on_upvote_button_click(inputs):
138
  inputs[feedback].save_feedback(like=1)
139
  gr.Info('Thanks for your feedback')
 
61
  with gr.Row():
62
  upvote_button = gr.Button('Upvote')
63
  downvote_button = gr.Button('Downvote')
64
+ feedback_textbox = gr.Textbox(lines=3, show_label=False, info='Press enter to submit')
 
65
  # components
66
  components = {
67
  point_coords, point_labels, raw_image, masks, cutout_idx,
68
+ feedback, upvote_button, downvote_button, feedback_textbox,
69
  input_image, point_label_radio, reset_btn, run_btn, masks_annotated_image}
 
70
  # event - init coords
71
  def on_reset_btn_click(raw_image):
72
  return raw_image, point_coords_empty(), point_labels_empty(), None, []
 
127
  masks_annotated_image.select(on_masks_annotated_image_select, components, [cutout_idx, cutout_galary, feedback], queue=False)
128
 
129
  # event - feedback
130
+ def on_feedback_textbox_submit(inputs):
131
  inputs[feedback].save_feedback(feedback_str=inputs[feedback_textbox])
132
  gr.Info('Thanks for your feedback')
133
  return inputs[feedback], None
134
+ feedback_textbox.submit(on_feedback_textbox_submit, {feedback, feedback_textbox}, [feedback, feedback_textbox], queue=False)
135
  def on_upvote_button_click(inputs):
136
  inputs[feedback].save_feedback(like=1)
137
  gr.Info('Thanks for your feedback')