How to create a Button which will be displayed only when the value of some global FrontEnd setting is False and will self-destruct with entire row of the Column after pressing it setting this value to True?
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 the Button does not disappear after pressing it. Is it possible to make it self-destructive?
The final solution based on ideas by 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]]
The key points are:
- introducing additional
Dynamicvariableband binding it with the value ofOptions[$FrontEnd, "VersionedPreferences"], - wrapping entire
Columnconstruct
withDynamicinstead of using
DynamicinsideColumn.
Perhaps
Edit
Answering your comment. Please try the following. Encompassing the
Column[ ]withDynamic[ ]allows resizing it: