4
$\begingroup$

I did what I believe was a thorough search on this topic, but still ended up fruitless. Apologies if there is a trivial solution to this.

Is there a way to group control objects together to form collapsible groups, much like cells in notebooks and the animation controls of manipulators? That is, the objects would form a group bound together, so that a click on a "plus" or an equivalent symbol would expand the group so that the objects can be seen and manipulated and another click would collapse the group again so that the objects are hidden.

If not, is there another way to handle a large number of controls/graphic objects?

$\endgroup$

3 Answers 3

2
$\begingroup$

You can place any controls inside an OpenerView:

OpenerView[{"ButtonGroup",
  Column[{
    Button["P5", Print[5!]],
    Button["P7", Print[7!]]
    }]
  }]

enter image description here

Instead of OpenerView you could also use TabView or SlideView. I use this quite often to group, hide and open controls within a complex Manipulate. Keeps the screen clean.

$\endgroup$
5
$\begingroup$

I'm adding this answer late because I think it would be good to have an example of OpenerView given as an argument to Manipulate, a common use-case for OpenerView. I also want to point out a special consideration which must be made when specifying controls in such a situation.

SeedRandom[3];
With[{nMax = 16, rMax = 12., extent = 300},
  With[{redPts = RandomReal[{12., extent - 12}, {nMax, 2}],
        blkPts = RandomReal[{12., extent - 12}, {nMax, 2}]},
    Manipulate[
      Graphics[{
        {Red, Disk[#, redR] & /@ redPts[[;; redN]]},
        {Black, Disk[#, blkR] & /@ blkPts[[;; blkN]]}},
        PlotRange -> {{0, extent}, {0, extent}}],
      OpenerView[{"Red",
        Column[{
          Control[{{redN, 1, "number"}, 0, nMax, 1, Slider}],
          Control[{{redR, 4., "radius"}, 4., rMax, 2., Slider}]}]},
        True, ImageSize -> extent],
      OpenerView[{"Black",
        Column[{
          Control[{{blkN, 1, "number"}, 0, nMax, 1, Slider}],
          Control[{{blkR, 4., "radius"}, 4., rMax, 2., Slider}]}]},
        True, ImageSize -> extent],
      FrameLabel -> {{None, None}, {None, Style["Random Spots", "SB", 14]}},
      ContentSize -> {extent, extent},
      ControlPlacement -> Bottom]]]

opener-view

The special consideration I want to be noticed is that the control descriptions, which would be lists had they been given directly as arguments to Manipulate, must be wrapped with Control when they are arguments of an argument of Manipulate.

$\endgroup$
2
$\begingroup$

Try this:

    OpenerView[{"", 
  Column[{a^2 + b^2, Plot[Sin[x], {x, 0, 2 \[Pi]}], 
    Speak["This is the opener view"]}]}]
$\endgroup$

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.