Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the background style of TabView?

When including a 3D plot inside a TabView, in my computer, the entire tab is grayed as if it was a giant button, leaving the Graphics with a white background:

example

To avoid the contrast between the gray and the white, I would prefer that the tab also had a white color.

Tried BaseStyle -> {Background -> White} but with no success (only the borders get restyled).

How can I change the Background color of the tab?

like image 1000
P. Fonseca Avatar asked Nov 29 '11 10:11

P. Fonseca


People also ask

How to change TabView color?

Step 1: Create a Model and ViewModel classes in Sample. Step 2: Create the Color property in the ViewModel class, and then set the color value. Step 3: Bind the Color property into View in the TabHeaderBackgroundColor property.

How do I add a tab bar in SwiftUI?

Press Cmd+N to create a new SwiftUI View, calling it “MainView”. Creating tabs is as easy as putting different views inside an instance of TabView , but in order to add an image and text to the tab bar item of each view we need to use the tabItem() modifier.


3 Answers

The default background is not white but transparent for graphics, so there's no harsh contrast. Background -> White makes the background white and leaves the borders, quite the opposite of what you said. BaseStyle doesn't seem to do anything.

This is what I get on Windows XP:

TabView

EDIT: An alternative is a custom TabView-implementation along the following lines:

objects = Table[Plot[f[x], {x, 0, 10}], {f, {Sin, Cos, Exp}}];

Column[
 {SetterBar[Dynamic[x], Thread[objects -> Range@Length[objects]]], 
  Dynamic[x]}
 ]

This is unfinished, but the basics work, and it shows you how to do it yourself.

like image 87
Szabolcs Avatar answered Nov 02 '22 09:11

Szabolcs


This seems to be an OS specific problem. On OS X, TabView does have a grey background (albeit very light), even with Background->White. For example

TabView[Table[Plot[Sin[i x], {x, 0, 2 Pi}, Background -> White], {i, 4}], 
  Background->White]

produces this

enter image description here

like image 45
Heike Avatar answered Nov 02 '22 09:11

Heike


I can confirm Heike's assertion for Windows 7.


If you wish to always overwrite the system theme color for TabView boxes, you may evaluate:

SetOptions[$FrontEnd,
  TabViewBoxOptions -> {Background -> GrayLevel[1]}
]

Using either the "Windows 7 Basic" or "Windows 7 Aero" theme, I see this:

enter image description here

However, using the "Windows Classic" theme I see this:

enter image description here

If, using the Classic theme, I open Window Color and Appearance and change the 3D Objects Color 1 to white, I see:

enter image description here

like image 3
Mr.Wizard Avatar answered Nov 02 '22 07:11

Mr.Wizard