3

I have controls in a Manipulate that I'm laying out in a Grid and I'd like globally set their widths (and other properties). For example, something like

Grid[{{Control@{{sx3, 1}, -10, 10}, ...}]

but

SetOptions[Slider,{ImageSize-> 150, Appearance->"UpArrow"}]

has no effect; and

ctl[c_]:=Control[Join[c,{ImageSize->150, Appearance->"UpArrow"}]]
Grid[{{ctl@{{sx3, 1}, -10, 10}, ...}]

gives errors.

The only approach that works is to set these options for each control with

Grid[{{Control@{{sx3, 1}, -10, 10, ImageSize-> 150, Appearance->"UpArrow"}, ...}]

How do I globally set control widths (inside of Grid), and other properties so that I can avoid having to set them for each of my controls individually?

orome
  • 12,819
  • 3
  • 52
  • 100

3 Answers3

7

As @Kuba point out, the default slider-like control for Manipulate is actually a Manipulator, so you can do it like this.

SetOptions[Manipulator, {ImageSize -> 150, Appearance -> "UpArrow"}];
Manipulate[
 {a, b, c, d},
 Grid[
   Map[
     Control,
     {{{a, 0, 1}, {b, 0, 1}}, {{c, 0, 1}, {d, 0, 1}}},
     {-2}]]]

demo

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
1

You can globally define

slide = 
  Slider[##, Appearance -> {Tiny, "UpArrow"}, Background -> GrayLevel[0.95]] &;

And then inside a Manipulate

Grid[{
  {"Lines", Control[{{nl, 4, ""}, 1, 128, 1, slide}]},
  {"Length", Control[{{sc, 0.5, ""}, 0.02, 2, 0.02, slide}]},
  {"Range", Control[{{rf, 1, ""}, 0.5, 2, slide}]}
  }, Alignment -> Left, Spacings -> {0.5, 1.2}]

enter image description here

Similarily with other controls.

Inside constructs like Grid, Column etc. you must use Control.

eldo
  • 67,911
  • 5
  • 60
  • 168
  • That still requires placing what is effectively a setting in each Control (albeit as a package). – orome Aug 05 '17 at 19:15
1

You can make your ctl function work with something like this:

Attributes[ctl] = HoldFirst;
ctl[{para__}] := Control[{para, ImageSize -> 150, Appearance -> "UpArrow"}]

Grid[{{ctl@{{sx3, 1}, -10, 10}}}]
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371