Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! –  belisarius Jan 8 at 17:47
add comment

2 Answers 2

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

share|improve this answer
    
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... –  Manu Jan 8 at 17:07
    
@Manu See edit please –  belisarius Jan 8 at 17:42
    
Ok, very well :-) Thanks –  Manu Jan 8 at 17:47
    
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}] –  Manu Jan 8 at 18:13
    
@Manu I used Invisible[] on purpose to preserve the appearance of the manipulate dialog –  belisarius Jan 8 at 18:18
show 1 more comment

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

share|improve this answer
    
So now I have a lot of possibilitys :-) –  Manu Jan 8 at 22:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.