3
$\begingroup$

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?

$\endgroup$
2
  • 4
    $\begingroup$ because it is not a Slider, try SetOptions[Manipulator, {ImageSize -> 220, Appearance -> "UpArrow"}] $\endgroup$
    – Kuba
    Aug 5, 2017 at 19:13
  • 1
    $\begingroup$ related: 32848 $\endgroup$
    – Kuba
    Aug 5, 2017 at 19:14

3 Answers 3

7
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ Yes, as @Kuba pointed out. $\endgroup$
    – orome
    Aug 5, 2017 at 20:10
  • 1
    $\begingroup$ @raxacoricofallapatorius. I have given him credit. $\endgroup$
    – m_goldberg
    Aug 5, 2017 at 20:12
1
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ That still requires placing what is effectively a setting in each Control (albeit as a package). $\endgroup$
    – orome
    Aug 5, 2017 at 19:15
1
$\begingroup$

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}}}]
$\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.