Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GetCode[] := Cell[BoxData[StyleBox[
- DynamicBox[ToBoxes[Refresh[
- InputForm @@ MakeExpression@
- First@First@
- Quiet[Cases[NotebookGet[EvaluationNotebook[]][[1]],
- Cell[___, CellTags -> "MyGraphic", ___], Infinity]]
- , UpdateInterval -> 1], StandardForm]
- ], StripOnInput -> False, LineColor -> GrayLevel[0.5],
- FrontFaceColor -> GrayLevel[0.5],
- BackFaceColor -> GrayLevel[0.5], GraphicsColor -> GrayLevel[0.5],
- FontColor -> GrayLevel[0.5]]
- ], "Output", CellTags -> "MyCode"];
- DynamicQ[] := (
- Length@Cases[
- Quiet[
- Cases[NotebookGet[EvaluationNotebook[]][[1]],
- Cell[___, CellTags -> "MyCode", ___], Infinity], First::first]
- , DynamicBox[___]
- , Infinity] == 1
- );
- CellPrint@Cell[BoxData[ToBoxes[
- Graphics[{Circle[]}, ImageSize -> {100, Automatic}]
- ]], "Output", CellTags -> "MyGraphic"];
- Print[Button["Diable/Enable Dynamic",
- If[DynamicQ[],
- NotebookLocate["MyCode"];
- code = InputForm @@ MakeExpression@
- First@First@
- Quiet[
- Cases[NotebookGet[EvaluationNotebook[]][[1]],
- Cell[___, CellTags -> "MyGraphic", ___], Infinity]];
- NotebookWrite[EvaluationNotebook[], Cell[BoxData[
- ToBoxes[code]
- ], "Input", CellTags -> "MyCode"]
- ];
- ,
- NotebookLocate["MyCode"];
- Quiet[
- NotebookWrite[EvaluationNotebook[], GetCode[]]
- ];
- ];
- ] Button["Update Graphics",
- NotebookLocate["MyGraphic"];
- NotebookWrite[EvaluationNotebook[], Cell[BoxData[
- ToBoxes@ToExpression[
- Cases[NotebookGet[EvaluationNotebook[]][[1]],
- Cell[BoxData[___], ___,
- CellTags -> "MyCode", ___], {1}][[1, 1]]
- ]
- ], "Input", CellTags -> "MyGraphic"]];
- ]
- ];
- CellPrint@GetCode[];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement