I am unable to use widgets in Jupyter to make something that actually should be simple but I can't make it work: I want a GUI where the user presses a 'Button' to update the content of a 'Label' based on value of 'FloatText'
I tried many things to no avail. Here two examples:
Example 1:
from ipywidgets import FloatText, Button, Label, interact
t_str1 = FloatText( description='Strain in %:', value='3' )
b_cs = Button( description='Compute Stress' )
t_str2 = Label( value='Waiting' )
display( t_str1 ); display( b_cs )
def compute_stress( x ):
t_str2 = Label( value='Stress = ' + str(x+3)+ 'MPa' )
display( t_str2 );
interact( compute_stress, x=t_str1 );
Result of example 1:
Example 2:
from ipywidgets import FloatText, Button, Label, interact
t_str1 = FloatText( description='Strain in %:', value='3' )
b_cs = Button( description='Compute Stress' )
t_str2 = Label( value='Waiting' )
display( t_str1 ); display( b_cs ); display( t_str2 );
def compute_stress( x ):
t_str2 = Label( value='Stress = ' + str(x+3)+ 'MPa' )
interact( compute_stress, x=t_str1 );
Result of example 2:
This is what I would like to obtain



