How to create Buttonone that will be displayed only when the value of any global FrontEnd installation is Falseand self-destructs with the entire line Columnafter clicking on it, setting this value toTrue
I need something like this:
Column[{"Item 1", "Item 2",
Dynamic[If[
Last@Last@Options[$FrontEnd, "VersionedPreferences"] === False,
Button["Press me!",
SetOptions[$FrontEnd, "VersionedPreferences" -> True]],
Sequence @@ {}]]}]
But with this code Buttondoes not disappear after clicking. Can this be made self-destructive?
Final decision based on the ideas of belisarius and mikuszefski :
PreemptProtect[SetOptions[$FrontEnd, "VersionedPreferences" -> False];
b = True];
Dynamic[Column[
Join[{"Item 1", "Item 2"},
If[Last@Last@Options[$FrontEnd, "VersionedPreferences"] === False &&
b == True, {Button[
Pane[Style[
"This FrontEnd uses shared preferences file. Press this \
button to set FrontEnd to use versioned preferences file (all the \
FrontEnd settings will be reset to defaults).", Red], 300],
AbortProtect[
SetOptions[$FrontEnd, "VersionedPreferences" -> True];
b = False]]}, {}]], Alignment -> Center],
Initialization :>
If[! Last@Last@Options[$FrontEnd, "VersionedPreferences"], b = True,
b = False]]
Key points are:
- introducing an additional variable
Dynamic band binding it to a value Options[$FrontEnd, "VersionedPreferences"], - packaging the entire structure
Column
using Dynamicinstead of using
Dynamicinside Column.