Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

Finally:

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.

share|improve this question
1  
Mm8 8.0 on WinXP: TabView[{a, b}, Background -> Yellow] i.stack.imgur.com/zwTYn.png –  belisarius Feb 21 '13 at 20:12
    
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. –  Oleksandr R. Feb 21 '13 at 20:27
    
@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. –  Jagra Feb 24 '13 at 15:29
    
@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. –  Jagra Feb 24 '13 at 15:52
    
@Jagra No, really not. Sorry. –  belisarius Feb 24 '13 at 18:54
show 1 more comment

2 Answers

up vote 7 down vote accepted

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]]

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

Mathematica graphics

share|improve this answer
    
Seems like the way to go, +1. I had hoped for a simpler life. –  Jagra Feb 21 '13 at 22:22
    
@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. –  Szabolcs Feb 21 '13 at 22:54
add comment

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

share|improve this answer
    
Thanks for the workaround wrapping the TabView elements in Panel and congratulations on reaching 10k. –  Jagra Feb 24 '13 at 15:24
add comment

Your Answer

 
discard

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.