4
$\begingroup$

I need your help with making a slider invisible and visible in a Manipulate. Here is my code:

Manipulate[{}, 
  {x, 0, 1}, 
  {y, 0, 1}, 
  {visible, 
    {"only x-slider visible", "only y-slider visible", "both visible"}, 
    ControlType -> PopupMenu}]

The PopupMenu shows how I want it to function.

$\endgroup$
0

2 Answers 2

5
$\begingroup$

Here is an option:

Manipulate[{},
  Dynamic@If[visible != "hide x-slider",
             Control[{x, 0, 1}],
             Invisible@Control[{x, 0, 1}]], 
  {visible, {"hide x-slider", "show x-slider"}, ControlType -> PopupMenu}]

Mathematica graphics

$\endgroup$
6
  • $\begingroup$ Ok, the part DynamicWrapper[Dynamic@If[]] I see nowhere before. Thanks for your help. Is there any other possibility to solve that problem? I can use x only as a normal slider, but can't open this slider with the plus... $\endgroup$
    – Manu
    Jan 8, 2014 at 17:07
  • $\begingroup$ @Manu See edit please $\endgroup$ Jan 8, 2014 at 17:42
  • $\begingroup$ Ok, very well :-) Thanks $\endgroup$
    – Manu
    Jan 8, 2014 at 17:47
  • $\begingroup$ I have another possibility without using Invisible@Control[]: Manipulate[{}, Dynamic@If[visible != "hide x-slider", Column[{Control[{x, 0, 1}], Control[{y, 0, 1}]}], Control[{y, 0, 1}]], {visible, {"hide x-slider", "show x-slider"}, ControlType -> PopupMenu}] $\endgroup$
    – Manu
    Jan 8, 2014 at 18:13
  • $\begingroup$ @Manu I used Invisible[] on purpose to preserve the appearance of the manipulate dialog $\endgroup$ Jan 8, 2014 at 18:18
4
$\begingroup$

A couple more ways.

PaneSelector, with a blank Row:

Manipulate[{x, y},
 PaneSelector[{True -> Control[{x, 0, 1}], False -> Row[{}]}, 
   Dynamic[visible != "only y-slider visible"]],
 PaneSelector[{True -> Control[{y, 0, 1}], False -> Row[{}]}, 
   Dynamic[visible != "only x-slider visible"]],
 {visible, {"only x-slider visible", "only y-slider visible", 
            "both visible"}, ControlType -> PopupMenu}]

Dynamic switch between Identity & Invisible:

Manipulate[{x, y},
 Dynamic[If[visible != "only y-slider visible", Identity, Invisible]@
   Control[{x, 0, 1}]],
 Dynamic[If[visible != "only x-slider visible", Identity, Invisible]@
   Control[{y, 0, 1}]],
 {visible, {"only x-slider visible", "only y-slider visible", 
            "both visible"}, ControlType -> PopupMenu}]

Mathematica graphics Mathematica graphics

$\endgroup$
2
  • $\begingroup$ So now I have a lot of possibilitys :-) $\endgroup$
    – Manu
    Jan 8, 2014 at 22:46
  • $\begingroup$ @Manu, make sure you've got that: Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – garej
    Aug 7, 2015 at 21:44

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.