ipywidgets
ipywidgets copied to clipboard
Wait for a button widget to be clicked
HI all, i am struggling with the following problem. I can't find a solution reading the documentation so i am asking here. Let's assume i want to deploy a feedback stage for a certain application. Let's assume i have a text-box for output and two button for input like the following:
import ipywidgets as ipw
from ipywidgets import Layout
txt_out=ipw.Textarea(
value='are you interested in leaving a feedback?',
disabled=True,
layout=Layout(border='solid 1px', width = '650px', height = '150px', )
)
yes=ipw.Button(
description='',
disabled=False,
button_style='info', # 'success', 'info', 'warning', 'danger' or ''
tooltip='Yes',
icon='thumbs-up',
layout=Layout(height='50px')
)
no=ipw.Button(
description='',
disabled=False,
button_style='info', # 'success', 'info', 'warning', 'danger' or ''
tooltip='No',
icon='thumbs-down',
layout=Layout(height='50px'))
box1=ipw.HBox([yes,no])
box2=ipw.VBox([txt_out,box1])
display(box2)
Wich results like:

How can i wait for the user press a button inside a function? I would use thread, but exactly wich function should i thread? I cant thread directly the on_click button function, am i right?
The goal is change txt_out.value according to user choice (multiple times, indeed). Appreciate your help
Thanks
Have you solved it? It's my question too.