# Help generating dynamic manipulators?

I would like to generate dynamic Manipulators for each of the selected buttons in a ToggleBar. How can I keep the state of each Manipulator in a variable? I would like to later access the values of the Manipulators for each of the selected buttons.

Thanks.

DynamicModule[{stakes = {}},
Column[{TogglerBar[Dynamic[stakes], {1.5, 3.5, 7, 15, 30, 60, 100,
200, 300, 500, 1000}],
Dynamic[Grid[({#, Manipulator[Appearance -> Labeled]}) & /@ Sort[stakes]]]}]]


m = {1.5, 3.5, 7, 15, 30, 60, 100, 200, 300, 500, 1000};
(x[#] = 0) & /@ m;
DynamicModule[{stakes = {}}, Column[{TogglerBar[Dynamic[stakes], m],
Dynamic[
Column@{Grid[({#,
Manipulator[Dynamic[x[#]], Appearance -> Labeled],
Dynamic[x[#]]}) & /@ Sort[stakes]],
Dynamic@Total[x /@ m]}]}]]


Edit

m = {1.5, 3.5, 7, 15, 30, 60, 100, 200, 300, 500, 1000};
(x[#] = 0) & /@ m;
DynamicModule[{stakes = {}},
Column[{TogglerBar[Dynamic[stakes], m],
Dynamic[Column@{Grid[({#,
Manipulator[Dynamic[x[#]],
Appearance -> Labeled], (Dynamic[
Quiet@Check[x[#]/Total[x /@ stakes], 0]])}) & /@
Sort[stakes]]}]}]]


• Thanks. I figured a similar solution but yours is much better. I was struggling to find a way to use Total over the array x since it is not a list and you can't use Total directly. So an array x is a function of its keys in Mathematica? At least that is how I interpret x /@ m.
– dabd
May 2, 2013 at 18:34
• Now I am struggling to add another feature: how to make the sliders always add to 1?
– dabd
May 2, 2013 at 20:06
• I think for my application it makes sense. Each slider represents the stakes of a game. If I am going to play 100 games then choosing 1.5 at 0.6 and 3.5 at 0.4 means I am playing 60 of the games at 1.5 stake and the remaining 40 at 3.5 stake. It does not make sense to say I am playing 100% of the games at 1.5 and 100% of the games at 3.5, for example.
– dabd
May 2, 2013 at 20:29
• Never mind I was confused, normalization makes sense for this case as well. Thanks.
– dabd
May 2, 2013 at 20:35
• I didn't know about the Quiet Check trick. However there is still one problem. If I click 15 and move the slider to 1, click 30 and move the slider to the somewhere below 1, then if you toggle 30, removing it the 15 slider will keep at a smaller value than 1.
– dabd
May 2, 2013 at 21:10