Guest User

Untitled

a guest
Aug 6th, 2013
50
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. This is my next attempt.
  2.  
  3. GetCode[] := Cell[BoxData[
  4. StyleBox[
  5. DynamicBox[ToBoxes[Refresh[
  6.  
  7. InputForm @@ MakeExpression@
  8.  
  9. First@First@
  10. Cases[NotebookGet[EvaluationNotebook[]][[1]],
  11. Cell[___, CellTags -> "MyGraphic", ___], Infinity]
  12.  
  13. , UpdateInterval -> 1], StandardForm]
  14. ], StripOnInput -> False, LineColor -> GrayLevel[0.5],
  15. FrontFaceColor -> GrayLevel[0.5],
  16. BackFaceColor -> GrayLevel[0.5], GraphicsColor -> GrayLevel[0.5],
  17. FontColor -> GrayLevel[0.5]]
  18. ], "Output", CellTags -> "MyCode"];
  19. DynamicQ[] := (
  20. Length@Cases[
  21. Cases[NotebookGet[EvaluationNotebook[]][[1]],
  22. Cell[___, CellTags -> "MyCode", ___], Infinity]
  23. , DynamicBox[___]
  24. , Infinity] == 1
  25. );
  26. CellPrint@Cell[BoxData[
  27. ToBoxes[
  28. Graphics[{Circle[]}, ImageSize -> {100, Automatic}]
  29. ]
  30. ], "Output", CellTags -> "MyGraphic"];
  31. Print[Button["Diable/Enable Dynamic",
  32. If[DynamicQ[],
  33. NotebookLocate["MyCode"];
  34. code = InputForm @@ MakeExpression@
  35. First@
  36. First@Cases[NotebookGet[EvaluationNotebook[]][[1]],
  37. Cell[___, CellTags -> "MyGraphic", ___], Infinity];
  38. NotebookWrite[EvaluationNotebook[], Cell[BoxData[
  39. ToBoxes[code]
  40. ], "Input", CellTags -> "MyCode"]
  41. ];,
  42. NotebookLocate["MyCode"];
  43. NotebookWrite[EvaluationNotebook[], GetCode[]];
  44. ];
  45. ] Button["Update Graphics",
  46. Print["test"];
  47. ]
  48. ];
  49. CellPrint@GetCode[];
RAW Paste Data