2
$\begingroup$

Is there a way to remove the braces from the front end output associated with DynamicModule? For instance:

a=0;
DynamicModule[{x}, {Slider[Dynamic[x]], Dynamic[If[x>.5,a=1;,{}]]}]

This returns a slider with braces around it. Is there a way to avoid or remove the braces?

$\endgroup$
6
  • 2
    $\begingroup$ Row@{Slider...? This is what you want? $\endgroup$
    – Kuba
    Sep 19, 2013 at 5:57
  • $\begingroup$ @Kuba: Yes! But can they also be eliminated from the Dynamic[If[...]]? $\endgroup$
    – user8454
    Sep 19, 2013 at 6:01
  • 2
    $\begingroup$ @user8454 does Dynamic[If[x > .5, a = 1;, Spacer[0]]] do what you want? $\endgroup$
    – Mr.Wizard
    Sep 19, 2013 at 6:02
  • $\begingroup$ Yes @Mr.Wizard! Sorry @Kuba! Thanks guys! $\endgroup$
    – user8454
    Sep 19, 2013 at 6:03
  • $\begingroup$ @Kuba Do you care to post both parts as an answer? $\endgroup$
    – Mr.Wizard
    Sep 19, 2013 at 6:04

1 Answer 1

5
$\begingroup$

Quick fix to your code would be to add Row and Spacer[0].

a=0;
DynamicModule[{x}, Row@{Slider[Dynamic[x]], Dynamic[If[x>.5,a=1;, Spacer[0]]]}]

Instead of Spacer[0] you can use empty string: "", or Invisible[""].

Those braces are in output because you put them there. To know more about organizing an output, take a look at documentation:

tutorial / Grids Rows and Columns overview

there are also interesting related Q&A-s here on Mathematica.SE, for example:

Why use Column with Rows instead of Grid?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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