2

I have created several Textarea widgets in Jupyter/Python in order to capture some string inputs.

In the highlighted in yellow that you can see below, the idea is that the user puts a list of numbers here (copied from Excel) and later I need to convert this text into a list or an array that contains these numbers (an iterable object). I have no idea how to do this. See:

enter image description here

When I print the type of this object that is called "plus" I get this:

print(type(plus))
<class 'ipywidgets.widgets.widget_string.Textarea'>

But, I am expecting to have something like this:

plus = [454, 555] 

Can I bounce some ideas off you to get this?

Thanks a lot!!!

1 Answer 1

1

If you have an ipywidget in general, you can observe its change and get its value as following.

foo = widgets.Textarea()
# to get the value
foo.value
# to do something on value change
def bar(change):
    print(change.new)
foo.observe(bar, names=['value'])

You will then have to format the string you get from the products value, but that shouldn't be too difficult.

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.