I'd like to control the appearance of the components of a TabView[] control. Such a control appears constructed of Buttons, ButtonBar, and Panel.

Some examples follow to illustrate my problem.

appearances = {"DialogBox", "Palette", "FramedPalette", "Frameless"};
Button[1, Print[1], Appearance -> #] & /@ appearances
ButtonBar[{1 :> Print[1], 2 :> Print[2]}, Appearance -> #] & /@ appearances
TabView[{a, b}, Appearance -> #] & /@ appearances

enter image description here

In the above code I can change the appearances of an individual Button[] but not buttons in a ButtonBar[] or a TabView[].

Button[1, Print[1], Background -> Yellow] 
ButtonBar[{1 :> Print[1], 2 :> Print[2]}, Background -> Yellow] 
TabView[{a, b}, Background -> Yellow] 

enter image description here

The above presents a similar problem. Note that in the ButtonBar[] you can see a yellow halo around the entire control.


Panel[a, ImageSize -> 100, Background -> Yellow]
TabView[{a, b}, ImageSize -> 100, Background -> Yellow]

enter image description here

A similar problem, I can affect Panel[] but not the panel component of a TabView[].

So, does anyway exist to reach settings that affect the component levels of a complex control?

Any workarounds appreciated.


As this seems relevant, I run version 9 on OS X.

  • 1
    $\begingroup$ Mm8 8.0 on WinXP: TabView[{a, b}, Background -> Yellow] i.stack.imgur.com/zwTYn.png $\endgroup$ – Dr. belisarius Feb 21 '13 at 20:12
  • $\begingroup$ I doubt if this is possible, especially on Mac OS where customizing the UI widgets is not exactly condoned by Apple. Aside from that, the range of possible customizations is probably too platform-specific as the widgets seem to be the standard ones provided by the underlying OS. You might have better luck building an interface in Java. $\endgroup$ – Oleksandr R. Feb 21 '13 at 20:27
  • $\begingroup$ @belisarius -- Very curious that it has changed in v9. Any speculation as to why? I ask, because it might help me/us better understand the direction of development. $\endgroup$ – Jagra Feb 24 '13 at 15:29
  • $\begingroup$ @OleksandrR. -- While I recognize that this doesn't appear possible, why Wolfram wouldn't have made it possible? At some level they build up these controls from components. What prevents developers from exposing the methods/attributes of the components? For that matter, why wouldn't they? Maybe I've missed something, but it seems like a trivial thing to do. Don't TabView controls already provide one the ability to change things at the same level of exposure e.g., one can change the text in a tab or the content of a panel, so why not the specific appearance? Just wondering. $\endgroup$ – Jagra Feb 24 '13 at 15:52
  • $\begingroup$ @Jagra No, really not. Sorry. $\endgroup$ – Dr. belisarius Feb 24 '13 at 18:54

You can always create your own custom controls. This is a lot of work, but it also gives you unlimited flexibility. You can even create completely new kinds of control.

Scroll down to the last section here to see an example.

If you're aiming for a custom TabView-like control, I'd start with PaneSelector.

Here's a primitive example (just a start, not meant for final use):

value = "one"

tab[text_] := 
 Style[Button[text, value = text, Appearance -> None, 
   ImageMargins -> 10], Background -> Hue[RandomReal[], 1, 1]]

  Row[tab /@ {"one", "two", "three"}],
  PaneSelector[{"one" -> 1, "two" -> 2, "three" -> 3}, 

Mathematica graphics

  • $\begingroup$ Seems like the way to go, +1. I had hoped for a simpler life. $\endgroup$ – Jagra Feb 21 '13 at 22:22
  • $\begingroup$ @Jagra There may be simpler ways, I'd wait for more answers. I'd only do this as a last resort. It's clear how to do it, but it's not pleasant. $\endgroup$ – Szabolcs Feb 21 '13 at 22:54

The answer is that yes, you can affect the appearance of components of a control but the problem in this case is that your list of appearances

appearances = {"DialogBox", "Palette", "FramedPalette", "Frameless"};

are only valid Button appearances and that is why they have no effect of ButtonBar or TabView. When you use valid appearances it works fine:

Button[1, Print[1], Appearance -> #] & /@ {"DialogBox", "Palette", 
  "FramedPalette", "Frameless"}
ButtonBar[{1 :> Print[1], 2 :> Print[2]}, 
   Appearance -> #] & /@ {"Horizontal", "Vertical", "Row"}
TabView[{a, b}, Appearance -> #] & /@ {"Limited"}

(although the example is a bit limited to fully display some of the appearances)

enter image description here

ButtonBar is just a construction in which buttons are placed in a grid. If you have a look at the underlying expression you will get a feel for how you can make your own customized ButtonBar:

Grid[{{Button[1, Null, Appearance -> {"AbuttingRight"}], 
   Button[2, Null, Appearance -> {"AbuttingLeft"}]}},
 Spacings -> {0, 0}]

enter image description here

Regarding Panel and TabView, you are right and this always feels like a limitation when using TabView (on Macs anyway). And on Macs nested TabView looks pretty horrible because of the "locked in" panelling. As a type of work around, not perfect by any means, I wrap my TabView elements in Panel:

TabView[{Panel[a, Background -> Yellow, ImageSize -> {578, 349}]}, 
 ImageSize -> {600, 400}]

enter image description here

  • $\begingroup$ Thanks for the workaround wrapping the TabView elements in Panel and congratulations on reaching 10k. $\endgroup$ – Jagra Feb 24 '13 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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