# How to avoid the pink background in GUIs without using Quiet

GUIs may generate warnings while internal evaluations are processed. In this example I intentionally introduce a line that will generate a warning. Warnings are useful, so I don't want to quiet them nor I can ensure that a fairly complicated GUI (thousands of lines of code) will never generate one. The problem is that once I read the warning I would like to remove the pink background from the GUI without having to recreate it all.

The lines below will generate the problem when the Checkbox is clicked. I want to remove the pink background after I see it, or maybe I want to fix the code such that the pink background never appears but the warning messages remain printed to the console.

As a side note, this program doesn't work in Windows if I remove the brackets from or rename menuItems[] to menuItems.

CreateDocument[
Panel@
DynamicModule[{gui, opt = 1, dummyList = {3, 4}, changeTabQ = True,
menuItems[] := Block[{}, Rest@dummyList; {1, 2}];
Labeled[Checkbox[Dynamic[changeTabQ,
(dummyList = {}; changeTabQ = #;) &]]
,
Dynamic[Refresh[
Replace[changeTabQ,
{True -> Panel@
PopupMenu[Dynamic[opt, (opt = #;
) &]
, {1, 2}
]
, False -> PopupMenu[Dynamic[opt, (opt = #;) &], menuItems[]]
}
]
, TrackedSymbols :> {changeTabQ}
]
]
]
]
, WindowSize -> {Scaled@.3, Scaled@0.3}
, DockedCells -> Cell["Docked"]
, WindowMargins -> {{0, Scaled@1}, {Scaled@0.8, 0}}
, WindowElements -> {"VerticalScrollBar", "HorizontalScrollBar",
"StatusArea", "MagnificationPopUp"}
, Deployed -> True
, Editable -> False
, Selectable -> False
, WindowTitle -> "Test UI"
]

• I should emphasize that the code in this example has been written with the purpose of triggering the problem, so using PaneSelector or other funcitons to "improve" the code may hide the problem I'm trying to highlight. – Ariel Sepulveda May 18 '15 at 18:05
• Comments under this question should explain your side question: 66767 – Kuba May 18 '15 at 18:08
• I've often found that Dynamic[Refresh[code, TrackedSymbols->{symbols}]] often doesn't work as expected unless the symbols tracked have DownValues (i.e. end with a square bracket). In this example I had such behavior, so to make it work I added the [] at the end of the variable changeTabQ. Additionally, alternating the use or Rule[TrackedSymbols,{symbols}] and RuleDelayed[TrackedSymbols, {symbols}] may also make a difference at the time of "making things work" as expected. – Ariel Sepulveda May 18 '15 at 18:16
• Is Preferences -> Messages -> Formatting error indications--> None the answer? – Kuba May 20 '15 at 17:48
• It seems like those options partially solve the problem as the pink background is gone. The Cell Bracket still contains the evidence of the warning message which I would also like to remove somehow. I assume that those preferences can also also be set in a programmatic way. That would be the best such that the user doesn't have to deal with that, but the programmer can handle that for all potential users. – Ariel Sepulveda May 22 '15 at 13:00

Suppress formatting errors by setting the necessary options for the actual notebook or for the front-end:

SetOptions[EvaluationNotebook[], AutoStyleOptions -> {
"FormattingErrorStyle" -> {FontColor -> RGBColor[1., 0.33, 0.33],
Background -> RGBColor[1., 0.33, 0.33, 0.15]},
"FormattingErrorTooltips" -> False,
"HighlightFormattingErrors" -> False
}]

• @Kuba Yes, thanks, I copied it from another answer directly, forgot to modify. However, I have no clue how to suppress the bracket-indication. – István Zachar Jun 20 '16 at 7:09
• OP needs that gone too but at least first part is shown in programmatical way. – Kuba Jun 20 '16 at 7:19
• @Kuba Well, I'm aware of that, but for now, this is my half-answer. Though one can always turn off cell brackets entirely via "ShowCellBracket". – István Zachar Jun 20 '16 at 9:39
• Yes, sorry, I thought so but future readers are not aware of that from the answer content only. Don't want to be picky either but after several months, future reader may wonder why the bracket is still orange. Maybe I'm overreacting :) – Kuba Jun 20 '16 at 9:52