visual studio code – ipywidgets intractive_output function is being called many times
When invoking interactive_output in a python notebook, the function given to it is being called many times at each invokation.
This problem happens in the notebook editor of vscode. In collab it shows once, as expected.
You may try to run my example:
import ipywidgets as widgets
from ipywidgets import interact
one = widgets.IntSlider(min=0, max=10)
two = widgets.IntSlider(min=0, max=100)
three = widgets.IntSlider(min=0, max=1000)
ui = widgets.HBox([one,two,three])
def func(x,y,z):
print (f"The first value is: {x+2}")
print(f"The second value is: {y*2}")
print(f"The third value is {z**2}")
out = widgets.interactive_output(func, {'x': one, 'y' : two, 'z': three})
display(ui, out)
I obviously wanted the output to show only once. Could you help me solve it?
Read more here: Source link
