0

Is there a way to create a widget in an Ipython notebook and to read out the state of this widget at a different position in the code?

I tried using

from ipywidgets import interact

def f(x):
 pass

interact(f,x=True)

As a result, f(x) is executed when I klick the generated checkmark. This is not what I need. Instead, I would like to read out the state of the ckeckmark at a different position in the code. What is the best way to implement that?

Jann
  • 635
  • 1
  • 6
  • 17

1 Answers1

0

If you have already created the widget x, then get x.value where you need it in the code. For a toggle widget this should return a boolean.

ac24
  • 5,325
  • 1
  • 16
  • 31