Why isn't ClearAll ["Global` *"] cleared from user-defined colors of local palette variables?

I created a custom palette with ActionMenu that runs ClearAll["Global`*"] . It performs the desired action, but the interface does not instantly update colors from black to blue (standard), as it happens when ClearAll["Global`*"] is executed directly from the laptop’s cell (it is updated only after something else is done ) Is there a way to trigger an update to the state of the frontend?

EDIT: Apparently this happens when I load a package from the palette (blue does not immediately update to black).

+4
source share
1 answer

Not quite elegant, but it works (the main loop needs to be called once after ClearAll):

 ActionMenu["Clear", {"Clear global variables" :> (ClearAll["Global`*"]; Block[{nb}, nb = CreateDocument[ExpressionCell[42, "Input"], Visible -> False]; SelectionMove[nb, All, Notebook]; SelectionEvaluate[nb]; NotebookDelete[nb];])}] 

Of course, you should use the new Mathematica 8 NotebookEvaluate function, but it doesn't seem to work here (i.e.

 ActionMenu["Clear", {"Clear global variables" :> (ClearAll["Global`*"]; Block[{nb}, nb = CreateDocument[ExpressionCell[42, "Input"], Visible -> False]; NotebookEvaluate[nb]; NotebookDelete[nb];])}] 

error message appears

 Could not process unknown packet "1". 
+6
source

Source: https://habr.com/ru/post/894817/


All Articles