MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Styling the selected Tab's label in TabView

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98266] Re: [mg98231] Styling the selected Tab's label in TabView
  • From: "David Park" <djmpark at comcast.net>
  • Date: Fri, 3 Apr 2009 20:11:37 -0500 (EST)
  • References: <10632504.1238754068531.JavaMail.root@m02>

Bryce,

If your labels are just strings then why use Graphics and Text to display
them?

labels = {"Bill", "Susan"};
DynamicModule[{selected}, 
 TabView[Table[
   With[{i = i}, 
    Style[labels[[i]], 
      FontWeight -> 
       Dynamic[If[i === selected, Bold, Plain]]] -> ("Hello " <> 
       labels[[i]] <> "!")], {i, Length[labels]}], Dynamic[selected]]]

But if you want to use Graphics then use the ImageSize Option to control the
size.

labels = {"Bill", "Susan"};
DynamicModule[{selected}, 
 TabView[Table[
   With[{i = i}, 
    Graphics[
      Style[Text[labels[[i]]], 
       FontWeight -> Dynamic[If[i === selected, Bold, Plain]]], 
      ImageSize -> 25, 
      PlotRangePadding -> .5] -> ("Hello " <> labels[[i]] <> 
       "!")], {i, Length[labels]}], Dynamic[selected]]]


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  


From: Bryce Schober [mailto:bryce.schober at dynonavionics.com] 

It seems that you can't set the LabelStyle of individual tabs in a TabView.
Starting with the example in my TabView->Examples->Scope->Control
documentation, I got to:

labels = {"Bill", "Susan"};
DynamicModule[
 {selected},
 TabView[
  Table[
   With[
    {i = i},
    Graphics[
      Style[
       Text[labels[[i]]],
       FontWeight -> Dynamic[
         If[i === selected,
          Bold,
          Plain
          ]
         ]
       ],
      ImageSize -> All,
      PlotRangePadding -> .5
      ] -> ("Hello " <> labels[[i]] <> "!")
    ],
   {i, Length[labels]}
   ],
  Dynamic[selected]
  ]
 ]

This manages to bold the selected tab, but ImageSize -> All isn't limiting
itself to the size of the Text[], and I'm not sure how to limit the
resulting tab size to only that required for the text display...

-- 
Bryce Schober





  • Prev by Date: Re: Dynamic 2D ListLinePlot PlotRange
  • Next by Date: Re: Joust in Mathematica
  • Previous by thread: Re: Styling the selected Tab's label in TabView
  • Next by thread: Re: Styling the selected Tab's label in TabView