Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  1. How does one get TabView to specify the colour of the Polygon?

  2. How does one put a label on the slider: label => "number of sides = {}".

    DynamicModule[{p, colour},
      Dynamic[Graphics[{colour, Polygon[CirclePoints[p]]}]],
      Slider[Dynamic[p], {3, 17, 1}, Appearance -> "Labeled"],
      Dynamic[TabView[{colour -> Green, colour -> Orange}]]

Note: Detailed Explanations welcome. Im a determined beginner. Does it have something to do with the way TabView interacts with Set?

share|improve this question
up vote 3 down vote accepted

TabView is for viewing. You can associate color changes with the second argument of TabView but it will be easier to just use what is designed for that, like SetterBar.

Moreover, the less inside Dynamic the better so instead of creating whole Graphics you can just tell the FrontEnd to take care of that colour and Polygon.

DynamicModule[{p = 3, colour = Green}
 Column @ {
     }, PlotRange -> 1
     Slider[Dynamic[p], {3, 17, 1}],
     "number of sides = {", Dynamic@p, "}"
     }, Spacer[5]
   SetterBar[Dynamic@colour, {Red, Green, Orange}]

enter image description here

share|improve this answer

I believe this is the natural and idiomatic way to do it:

Manipulate[Graphics[{colour, Polygon[CirclePoints[sides]]}], 
           {sides, 3, 17, 1},
           {{colour, Orange}, {Green -> "Green", Orange -> "Orange"}} ]

Mathematica graphics

share|improve this answer
The guy is trying to use DynamicModule, don't put him off the right path! :) – Kuba Jan 21 at 8:43
@Kuba Are you the same Kuba who posted that entangled solution above? :D – Dr. belisarius Jan 21 at 8:45
Yep :) I think Manipulate is ok if you are not going to care about details and your apps are going to be relatively small. Otherwise habits from extensive use of Manipulate will drive you crazy :) And you know that! :) – Kuba Jan 21 at 8:48

This is more or less directly cribbed from the help:

Manipulate[Graphics[{color, Polygon[CirclePoints[sides]]}],
{{sides, 3,"Number of Sides"}, 3, 17, 1}, {color, Green}]

Mathematica graphics

share|improve this answer

Your Answer


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.