Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for a button widget to be clicked #3145

Open
lodm94 opened this issue Mar 3, 2021 · 1 comment
Open

Wait for a button widget to be clicked #3145

lodm94 opened this issue Mar 3, 2021 · 1 comment

Comments

@lodm94
Copy link

lodm94 commented Mar 3, 2021

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:

image

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

@msat59
Copy link

msat59 commented Dec 30, 2021

Have you solved it?
It's my question too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants