MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Grouping and constraining slider controls

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91283] Re: Grouping and constraining slider controls
  • From: "David Park" <djmpark at comcast.net>
  • Date: Wed, 13 Aug 2008 04:40:36 -0400 (EDT)
  • References: <g7riie$i8e$1@smc.vnet.net>

Tim,

Here is one possible solution using three sliders. We use the second 
argument of Dynamic to calculate the value of the slider and other 
variables. See the section 'The Second Argument of Dynamic' in the 
'Introduction to Dynamic' tutorial. (And why or why doesn't WRI put section 
openers in their tutorials? Especially since the brackets are also omitted. 
The scroll went out of fashion 2000 years ago - and for good reason! 
http://en.wikipedia.org/wiki/Codex#History)

Module[
 {x1 = 100, x2 = 0, x3 = 0, total = 100},
 Column[
  {Slider[
    Dynamic[x1, (total = # + x2 + x3;
       If[total > 100, {x1, x2, x3} = 100/total {#, x2, x3},
        x1 = #]) &], {0, 100}],
   Slider[
    Dynamic[x2, (total = x1 + # + x3;
       If[total > 100, {x1, x2, x3} = 100/total {x1, #, x3},
        x2 = #]) &], {0, 100}],
   Slider[
    Dynamic[x3, (total = x1 + x2 + #;
       If[total > 100, {x1, x2, x3} = 100/total {x1, x2, #},
        x3 = #]) &], {0, 100}],
   Dynamic@{x1, x2, x3, x1 + x2 + x3}}]
 ]


-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


"Tim Heger" <timheger at yahoo.com> wrote in message 
news:g7riie$i8e$1 at smc.vnet.net...
> Hello
>
> First - I am as green as it comes to Mathematica and have tried to RTFM
> to find my answer but alas I have come up short and need some help.  I
> want to group X number of slider controls that each have a value range
> from 0 to 100 and constrain this group so that the total of the values
> from the group is not greater than 100 (representing 100%).  So in
> theory slider 1 starts at 100% and has other sliders are moved they
> decrement proportionally the other sliders that are currently greater
> than 0.
>
> Thanks in advance from not berating this newbie too bad <grin>....
>
> Tim Heger
>
> 



  • Prev by Date: Re: fractional derivative (order t) of (Log[x])^n and Log[Log[x]]
  • Next by Date: Trouble Implementing Schelling's Segregation Model
  • Previous by thread: Re: Grouping and constraining slider controls
  • Next by thread: fractional derivative (order t) of (Log[x])^n and Log[Log[x]] etc.?