3
$\begingroup$

I have the following, simplified program:

import = {{"one", 1, 2, 3}, {"two", 4, 5}, {"three", 6, 7, 8, 9}};

Manipulate[
 s = Select[import, MemberQ[#, e] &];
 calc,
 {e, {"one", "two", "three"}},
 {calc, Rest[s[[1]]]}
 ]

The second setterbar displays numbers. Now, when clicking e.g. "two" in the first setterbar, I'd like that in the second setterbar the numbers update to 4 and 5. Then when clicking e.g. "three" in the first setter bar, the second setter bar updates to 6 7 8 9, and so on. The s is a much larger and more complex imported file, and the 'calc' is a more complex operation, but this should outline the principle – and basic problem.

$\endgroup$
2
  • $\begingroup$ I think not really. The critical point is, that when clicking e.g. "one" in the first setterbar, the second setterbar should update to '4 5' which seems not doable with TrackingFunction (I think). $\endgroup$ Commented Dec 7, 2016 at 9:32
  • $\begingroup$ I see, something like: mathematica.stackexchange.com/q/33402/5478 $\endgroup$
    – Kuba
    Commented Dec 7, 2016 at 10:03

1 Answer 1

1
$\begingroup$

I think you want to use ControlType to fix the type of controller, and I would suggest using an Association to quickly select the values, like this:

(*Association of e to calc values*)
import = <|"one" -> {1, 2, 3}, "two" -> {4, 5}, "three" -> {6, 7, 8, 9}|>;

Manipulate[
  s = Select[import, MemberQ[#, e] &];
  calc,

  {e, {"one", "two", "three"}},
  (*Here we make calc depend on the value of e by just using it in the variable spec*)
  {calc, import[e], ControlType -> TogglerBar}
]

First SEcond

$\endgroup$
1
  • $\begingroup$ Great! Thanks a lot. $\endgroup$ Commented Dec 7, 2016 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.