Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please explain how to get state of checkbox for its usage in further calculations. And I want to keep the selection from session to session without external savings. Thanks in advance

share|improve this question

You can use DynamicModule.

"Symbols specified in a DynamicModule will by default have their values maintained even across Mathematica sessions." (ref. DynamicModule)

 If[ValueQ[reportx], x = reportx, reportx = x = False];
 Checkbox[Dynamic[x, (reportx = x = #) &]], 
 Initialization :> (reportx = x)]

enter image description here

The default value of x/reportx is set to False.

It should only be necessary to evaluate the module once; re-evaluation does not reset anything though.

Note that you will need to keep the checkbox output cell in the notebook since the output is where the dynamic value is held. If you delete the output cell and save the notebook the value of x is gone.

There is an interesting Mathgroup post from John Fultz about that here.

share|improve this answer
Recalculation of nb resets value of checkbox – SergeyFomin Sep 21 '12 at 10:17
Guys from Mars wrote and use this mma, I cant understand anything for two weeks, lets take a pen&paper – SergeyFomin Sep 21 '12 at 10:56
@ celtschk - I fixed the re-evaluation check. – Chris Degnen Sep 21 '12 at 11:36
Congratulations!Another pair of shoes!It`s necessary to add this example to poor mma documentation – SergeyFomin Sep 21 '12 at 12:01
The check against True and False can be replaced with checking ValueQ Which is nicer, since it will work for other dynamic values as well as booleans. – jVincent Sep 21 '12 at 13:20
up vote 3 down vote accepted

I find answer in Help system! It's necessary to write

a = DynamicSetting[Checkbox[]] and evaluate it in place by Cntrl+Shft+Enter. That`s all!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.