Ask Your Question
0

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

asked 2016-05-28 19:04:33 +0200

sensen gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-05-28 23:50:19 +0200

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.

edit flag offensive delete link 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.

sensen gravatar imagesensen ( 2016-05-29 19:20:43 +0200 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2016-05-28 19:04:33 +0200

Seen: 171 times

Last updated: May 28 '16