Self-destructive button inside a column

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.
+3
2

PreemptProtect[SetOptions[$FrontEnd, "VersionedPreferences" -> False]; b = True]; 

Column[{"Item 1", "Item 2", Dynamic[
   If[Last@Last@Options[$FrontEnd, "VersionedPreferences"]===False && b == True, 
    Button["Here!", SetOptions[$FrontEnd, "VersionedPreferences"->True];b=False], 
   "Done"]]}]

Edit

. . Column[ ] Dynamic[ ] :

PreemptProtect[SetOptions[$FrontEnd, "VersionedPreferences" -> False]; b = True]; 
Dynamic[
  Column[{
   "Item 1", 
   "Item 2",
   If[Last@Last@Options[$FrontEnd, "VersionedPreferences"] === False && b == True, 
    Button["Press me!", SetOptions[$FrontEnd, "VersionedPreferences" -> True]; b=False], 
    Sequence @@ {}]}]]
+6

, , , :

x = True;

[ [{ [ "reset", x = True],   [x, Button [ "Press me", x = False]]}]  ]

+4

All Articles