TransWikia.com

Creating a Button to evaluate initialization cells

Mathematica Asked on July 20, 2021

I am trying to create a setup where I have a number of InputField, SetterBar, and Checkbox with Dynamic in the first cell of my notebook where I can set some options/values, and then have a Button which executes the initialization cells once these parameters have been chosen.

I was trying to understand how to use FrontEndTokenExecute["EvaluateInitialization"], but when I put this in a cell and run it, I get the following output and the evaluation cells don’t get executed, let alone when I put it inside of a Button (in which case nothing happens at all):

RefLink[TextCell[ RawBoxes["FrontEndToken"]], paclet : ref/FrontEndToken]["EvaluateInitialization"]

which looks like this
enter image description here


Problem solved: I had copied and pasted the FrontEndTokenExecute out of the Mathematica documentation window and it copied as a hyperlink, thus the RefLink. Replacing it with plain text fixed it and the button works as expected.

One Answer

Try this:

Button[Style["Before reading this notebook, press me", Bold, 
  Darker@Red], 
 FrontEndExecute[FrontEndToken["EvaluateInitialization"]]]

Correct answer by Alexei Boulbitch on July 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP