Ask Your Question
0

Interact: getting a slider to change its range

asked 2012-08-06 04:49:11 -0600

anonymous user

Anonymous

How would I get a slider to change its range when the stuff in the input box before it is changed?

Making two interacts somehow doesn't seem to work...

edit retag flag offensive close merge delete

Comments

1

I understand that "sliders that depend on sliders" is a feature that is coming soon. You can see a sample at: http://interact.sagemath.org/node/15. But, it's not in the standard Sage distribution yet.

calc314 gravatar imagecalc314 ( 2012-08-06 10:53:18 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-06-18 16:52:52 -0600

Since this functionality has yet to appear explicitly, one solution is to nest interacts. Here's a slider that depends on a slider (live example):

@interact
def _( n=slider(1,10) ):

  @interact
  def _( m=slider(0,n,default=n/2) ):

        show( 'n=', n )
        show( 'm=', m )

And here's a slider that depends on an input box as per the original question (live example):

@interact
def _( n=input_box(10) ):

  @interact
  def _( m=slider(0,n,default=n/2) ):

        show( 'n=', n )
        show( 'm=', m )
edit flag offensive delete link more

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: 2012-08-06 04:49:11 -0600

Seen: 374 times

Last updated: Jun 18 '16