3
$\begingroup$

When I go to the web page, https://reference.wolfram.com/language/ref/TabView.html, giving the description of TabView, the example displays as follows:

enter image description here

Note that the background for the label is blue. When I go to the same reference page in my Mathematica system, the example looks like the following:

enter image description here

The background color I get is black, making it impossible to read the label which is also black. How can I change this label background color? I have tried the following:

enter image description here

I am running Mathematica version 12.0.0.0 on Mac OS X Mojave version 10.14.6. The documentation says that TabView by default displays the labels in TabViewLabel Style, which typically uses the system button font. But buttons do not appear like this in other applications that I run on my Mac.

So how can I change the label background color or how can I change the TabViewLabel style?

Additional information: When I use other applications on my Mac that has tabs, the tabs appear correctly with selected tabs displaying with white letters on a blue background.

Example:

enter image description here

It is only in Mathematica that all my tabs have the selected tab displayed with black letters on a black background (so they are unreadable). I see this behavior everywhere, not just in programs I am writing. For example, I see this behavior when I look at help pages or when I look at the option inspector. So it must be some Mathematica setting that I have set wrong.

Anyone have any ideas?

$\endgroup$
  • 1
    $\begingroup$ I suspect I might have to change some option in the option inspector, but I don't see any option to change label background colors. $\endgroup$ – Stanley Rabinowitz Jan 4 at 15:55
  • $\begingroup$ Have you changed any of the top set of default settings in System Preferences... > General? $\endgroup$ – m_goldberg Jan 4 at 23:27
  • $\begingroup$ Also, are you using a stylesheet other than the Default stylesheet? $\endgroup$ – m_goldberg Jan 4 at 23:39
  • $\begingroup$ @m_goldberg I have not set anything to black in general system preferences. Appearance is set to light and accent color is set to blue. Thanks for the idea. $\endgroup$ – Stanley Rabinowitz Jan 5 at 0:29
  • $\begingroup$ @m_goldberg I don't know much about stylesheets and perhaps I've accidentally set something I shouldn't have set. When I choose Format>Edit Stylesheet, it says my notebook is inheriting base definitions from stylesheet "Default.nb". Is there anything else I should check? When I choose Format>Stylesheet, I see a submenu. No menu items are checked. Should I select "Default"? $\endgroup$ – Stanley Rabinowitz Jan 5 at 0:42
2
$\begingroup$

This will be an answer if it works on your system as it does on mine, and if you don't think its too much fussy code to bother with. Admittedly, it is more a work-around than a real solution. It does have the advantage of being fairly easy to modify to accommodate more elaborate tab view emulations.

With[{systemBlue = RGBColor[0., .5, 1., .75]},
  With[
    {colors = <|True -> {systemBlue, White}, False -> {White, Black}|>, 
     gray = GrayLevel[.6]},
    btnLbl[i_, state_] :=
      Module[{tabColor, textColor},
        {tabColor, textColor} = colors[state[[i]]];
        Graphics[
          {EdgeForm[{AbsoluteThickness[.5], gray}], FaceForm[tabColor], 
           Rectangle[{0, 0}, {1, 1}], 
           Text[Style[i, textColor], {.5, .5}]},
          ImageSize -> {20, 20}]];
    DynamicModule[{val, vals, n, state},
      vals = {a, b, c, d};
      n = Length[vals];
      state = ConstantArray[False, n];
      state[[3]] = True;
      Column[
        {Dynamic @
           Row[
             Button[btnLbl[#, state],
               state = ConstantArray[False, n];
               state[[#]] = True,
               Appearance -> None] & /@ Range[n],
         "\[NegativeVeryThinSpace]"], 
         Dynamic @
           Panel[Style[Pick[vals, state][[1]], 14], ImageSize -> 80]},
        Center,
        Spacings -> -.2],
      TrackedSymbols :> {state},
      SaveDefinitions -> True]]]

tabview

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for all the effort you have expended to solve my problem. It works and gives me a way to produce a TabView that looks like it is supposed to. But, as you say, it is a work-around. It would still be nice to figure out why the default TabView isn't working correctly on my system. I can now write programs that have nice-looking tab views, but when I look at the help system or the option inspector, I still see tabs that I cannot read because the selected tab shows black text on a black background. $\endgroup$ – Stanley Rabinowitz Jan 5 at 20:28
  • $\begingroup$ If someone gives me a program they wrote that looks nice on their machine, when I run it on my machine, any tabViews displayed by their program will display with black on black selections. I must have some global setting set wrong that is specifying that the background for selected tabs should be black rather than system blue. Any other thoughts? $\endgroup$ – Stanley Rabinowitz Jan 5 at 20:31
  • $\begingroup$ @StanleyRabinowitz. It's too bad you don't find this useful, but I suspected you might not. I understand your core concern is to getSetterBar (that's where the problem really is) to display as it should. I don't have an further ideas at this time except that you might contact Wolfram tech support if your Mathematica license includes tech support as some licenses do. $\endgroup$ – m_goldberg Jan 5 at 23:41
1
$\begingroup$

This is not an answer, but two code snippets to try in order to get more information on what is going on. Each snippet imitates a tab view by combining a setter bar with a panel. I would like you try them to see if one or both behave like the tab views you are getting. Please report your findings in comment below.

  1. Should produce system blue background on selected tab.

    DynamicModule[{j, vals, n},
      vals = {a, b, c, d};
      n = Length[vals];
      Column[
        {SetterBar[Dynamic[x], vals],
         Dynamic[Panel[Style[x, 14], ImageSize -> 80]]},
       Center,
       Spacings -> 0]]
    

    blue_tab

  2. Should produce gray background on selected tab.

    DynamicModule[{j, vals, n},
      vals = {a, b, c, d};
      n = Length[vals];
      Column[
        {SetterBar[Dynamic[x], vals, Appearance -> "Horizontal" -> {1, n}], 
         Dynamic[Panel[Style[x, 14], ImageSize -> 80]]},
        Center,
        Spacings -> 0]]
    

    gray_tab

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ snippet 1 gave me a black background on the selected tab. The background of the other tabs were white. snippet 2 gave me a gray background on the selected tab. The background of the other tabs were a lighter gray. $\endgroup$ – Stanley Rabinowitz Jan 5 at 2:35
  • $\begingroup$ @Thanks for the info. I conclude from your results that TabView is using SetterBar and that problem resides in SetterBar. Maybe I can do something now that I know where the problem really is. $\endgroup$ – m_goldberg Jan 5 at 3:41

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.