Ask Your Question

# is it possible for dynamic update the input_box in @interact part?

still new to Sage. followed the pre_tutorials and online ingteract wiki examples.

try to realize the function code like bellow. given the relationship between V and P is V=P+107, and two input_box are defined.

@interact def _(P=input_box(20, width=6, label="power(dBm)"),V=input_box(127, width=6, label="voltage(dBuV)")): V=P+107

want to realize when I input the new number to the input_box of P, then the input_box of V will dynamically update the value base on the relationship of V=P+107. and vice versa

edit retag close merge delete

## 1 answer

Sort by ยป oldest newest most voted

You can certainly nest interacts so that the first input modifies the second:

@interact
def _(P=input_box(20, width=6, label="power(dBm)")):
@interact
def _(V=input_box(P+107, width=6, label="voltage(dBuV)")):
show('P=',P)
show('V=',V)


Example output here. I don't think the vice versa part is currently possible.

more

## Comments

sorry for the late reply. I checked the documents again. didn't find the method to update the value of the input_box. so maybe this way is not possible. To make the convert function simple and logical. maybe using one input_box, one result area, and with two button. the two button control the convert logic and show the result explanation text.

( 2016-05-29 12:20:43 -0600 )edit

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2016-05-28 12:04:33 -0600

Seen: 48 times

Last updated: May 28 '16