Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: Styling the selected Tab's label in TabView
  • From: "David Park" <djmpark at comcast.net>
  • Date: Sun, 5 Apr 2009 06:31:42 -0400 (EDT)
  • 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: Can't figure out how to export Mathematica into Word
  • Next by Date: Re: Graphics and DisplayFunction
  • Previous by thread: Re: Styling the selected Tab's label in TabView
  • Next by thread: Dynamic 2D ListLinePlot PlotRange