Previous-Next button instead of slider in Mathematica?

Is it possible to use some Previous-Next buttons instead of a slider, as in the example below, when the monitored value is discrete?

I found the Manipulator one pretty ugly and would like some Setter types to be, if possible.

Manipulate[
           Graphics[
                    {
                     Rectangle[{1, 1}, {3, 3}],
                      Circle[{where, 2}, 1]
                    }, 
                     PlotRange -> {{0, 11}, {0, 3}}, ImageSize -> {300, 60}
                    ],
           {where, 1, 10, 1, Slider}
          ]

enter image description here

+3
source share
3 answers

You can create your own controls using the Buttonfollowing:

Manipulate[
 Graphics[
  {Rectangle[{1, 1}, {3, 3}],
   Circle[{where, 2}, 1]},
  PlotRange -> {{0, 11}, {0, 3}},
  ImageSize -> {300, 60}
  ],
 {{where, 1, ""}, 
  Button["Prev", where = Max[1, where - 1], Appearance -> "Palette", 
    ImageSize -> {50, Automatic}] &},
 {{where, 1, ""}, 
  Button["Next", where = Min[10, where + 1], Appearance -> "Palette",
    ImageSize -> {50, Automatic}] &},
 ControlPlacement -> Left]

enter image description here

+5
source

, Manipulate, Mathematica , . Manipulator, Slider ( ) , , /, .. :

Manipulate[
 Graphics[{Rectangle[{1, 1}, {3, 3}], Circle[{where, 2}, 1]}, 
  PlotRange -> {{0, 11}, {0, 3}}, ImageSize -> {300, 60}], {where, 1, 
  10, 1, Manipulator, Appearance -> "Open", 
  AppearanceElements -> {"StepLeftButton", "StepRightButton"}}]

, SO, , , : Appearance-> Open .

: , , .

AppearanceElements -> {"StepLeftButton", "StepRightButton"}

.

, .

Manipulate[
 Graphics[{Rectangle[{1, 1}, {3, 3}], Circle[{where, 2}, 1]}, 
  PlotRange -> {{0, 11}, {0, 3}}, ImageSize -> {300, 60}], {where, 1, 
  10, 1, ControlType -> Trigger, 
  AppearanceElements -> {"StepLeftButton", "StepRightButton"}}]

enter image description here

+4

As Yoda showed, Buttonit can be used for Next and Previous's buttons Manipulate. Buttons of this type are often used to go through a limited circle of objects. At the beginning and end of this range, the Previous and Next buttons should be disabled, respectively. For this to work, you can use the button property Enabledand, since its effect depends on the interactively changing value, is required Dynamic. The following toy example shows how this works.

Code example:

votePictures[picturesInput_] :=
 DynamicModule[{pictures = picturesInput, status, i},
  status = Table["Not Voted", {Length[pictures]}];
  i = 1;
  Panel[
   Row[
    {
     Dynamic[Show[pictures[[i]], ImageSize -> 256]], Spacer[72 0.7],
     Column[
       {
        Row[{Style["Status  ", FontFamily -> "Arial-Bold"], 
          SetterBar[
           Dynamic[status[[i]]], {"No response", "Ugly", "Nice"}]}
        ], , ,
        Row[{
           Button["Previous", i -= 1, Enabled -> (i > 1)], 
           Button["Next", i += 1, Enabled -> (i < Length[pictures])]}
        ] // Dynamic,
        Row[
            {
             Style["Picture   ", FontFamily -> "Arial-Bold"], 
             Slider[Dynamic[i], {1, Length[pictures], 1},Appearance -> "Labeled"]
            }
        ], , ,
        Button["Save results", (*Export code here *)]
        }
       ] // Framed
     }
    ], ImageSize -> 750
   ]
  ]

pictures = ExampleData[#] & /@ ExampleData["TestImage"]

votePictures[pictures]

enter image description here

+3
source

All Articles