Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

I think you should change your setup a little bit.

Including procedures inside Dynamics is useful somethimes, for better events handling, but nothing fancy is going on here. Thus it is better schedule calculations in a more stable way, by moving the Grid generation outside Dynamic.

Your exporting procedure clearly expects myplots to have an up to date value with respect to expr.

expr=values;
Export["file.png", myplots];

So keeping myplots=Grid[...] in a Dynamic is not a stable solution.

Why it is better to keep "procedures" outside and use Dynamics only for displaying things?

  • You can force FinishDynamic[] before the Export but if your Dynamic[myplots...] is not currently visible on a screen it won't be updated and assigned anyway.

  • ref: "FinishDynamic[] does not return until all Dynamic objects are updated and displayed. " - "all" sounds like an overkill for our purpose, doesn't it?

  • Dynamic[ myplots=Grid[...] ] requests this Grid calculation over the PreemptiveLink, it will timeout after DynamicEvaluationTimeout (6 seconds by default) and it will freeze other FrontEnd activities till it is finished.

Which isn't critical since you can icrease the timeout limit or use SynchronousUpdating -> False (runs on the MainLink), but why complicate things.

If something is not clear I'm encouraging you to lookup those symbols in Help and read Advanced Dynamic Functionality tutorial (and related)

What I'd change is the following:

  • create a plot updating procedure (for flexibility and readability)

      updatePlot[]:= (myplots=Grid[...]);
    

You can put it in DynamicModule's Initialization.

  • insert it in the exporting procedure

      expr=values;
      updatePlot[];
      Export["file.png", myplots];
    
  • change your Dynamic content:

      Dynamic[expr;myplots, TrackedSymbols:>{expr}]
    

Notice expr;, even though it is mentioned in TrackedSymbols it has to be explicitly stated in Dynamic's body to be properly tracked.

I think you should change your setup a little bit.

Including procedures inside Dynamics is useful somethimes, for better events handling, but nothing fancy is going on here. Thus it is better schedule calculations in a more stable way, by moving the Grid generation outside Dynamic.

Your exporting procedure clearly expects myplots to have an up to date value with respect to expr.

expr=values;
Export["file.png", myplots];

So keeping myplots=Grid[...] in a Dynamic is not a stable solution.

Why it is better to keep "procedures" outside and use Dynamics only for displaying things?

  • You can force FinishDynamic[] before the Export but if your Dynamic[myplots...] is not currently visible on a screen it won't be updated and assigned anyway.

  • ref: "FinishDynamic[] does not return until all Dynamic objects are updated and displayed. " - "all" sounds like an overkill for our purpose, doesn't it?

  • Dynamic[ myplots=Grid[...] ] requests this Grid calculation over the PreemptiveLink, it will timeout after DynamicEvaluationTimeout (6 seconds by default) and it will freeze other FrontEnd activities till it is finished.

Which isn't critical since you can icrease the timeout limit or use SynchronousUpdating -> False (runs on the MainLink), but why complicate things.

If something is not clear I'm encouraging you to lookup those symbols in Help and read Advanced Dynamic Functionality tutorial (and related)

What I'd change is the following:

  • create a plot updating procedure (for flexibility and readability)

      updatePlot[]:= (myplots=Grid[...]);
    

You can put it in DynamicModule's Initialization.

  • insert it in the exporting procedure

      expr=values;
      updatePlot[];
      Export["file.png", myplots];
    
  • change your Dynamic content:

      Dynamic[expr;myplots, TrackedSymbols:>{expr}]
    

Notice expr;, even though it is mentioned in TrackedSymbols it has to be explicitly stated in Dynamic's body to be properly tracked.

  • additionaly you can introduce progress state variable to show a ProgressIndicator instead of myPlots before they are recalculated. Analogously to Palette button with progress bar, which is nice from user perspective.

I think you should change your setup a little bit.

Including procedures inside Dynamics is useful somethimes, for better events handling, but nothing fancy is going on here. Thus it is better schedule calculations in a more stable way, by moving the Grid generation outside Dynamic.

Your exporting procedure clearly expects myplots to have an up to date value with respect to expr.

expr=values;
Export["file.png", myplots];

So keeping myplots=Grid[...] in a Dynamic is not a stable solution.

Why it is better to keep "procedures" outside and use Dynamics only for displaying things?

  • You can force FinishDynamic[] before the Export but if your Dynamic[myplots...] is not currently visible on a screen it won't be updated and assigned anyway.

  • ref: "FinishDynamic[] does not return until all Dynamic objects are updated and displayed. " - "all" sounds like an overkill for our purpose, doesn't it?

  • Dynamic[ myplots=Grid[...] ] requests this Grid calculation over the PreemptiveLink, it will timeout after DynamicEvaluationTimeout (6 seconds by default) and it will freeze other FrontEnd activities till it is finished.

Which isn't critical since you can icrease the timeout limit or use SynchronousUpdating -> False (runs on the MainLink), but why complicate things.

If something is not clear I'm encouraging you to lookup those symbols in Help and read Advanced Dynamic Functionality tutorial (and related)

What I'd change is the following:

  • create a plot updating procedure (for flexibility and readability)

      updatePlot[]:= (myplots=Grid[...]);
    

You can put it in DynamicModule's Initialization.

  • insert it in the exporting procedure

      expr=values;
      updatePlot[];
      Export["file.png", myplots];
    
  • change your Dynamic content:

      Dynamic[expr;myplots, TrackedSymbols:>{expr}]
    

Notice expr;, even though it is mentioned in TrackedSymbols it has to be explicitly stated in Dynamic's body to be properly tracked.

  • additionaly you can introduce progress state variable to show a ProgressIndicator instead of myPlots before they are recalculated. Analogously to Palette button with progress bar, which is nice from user perspective.
added 84 characters in body
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

I think you should change your setup a little bit. 

Including procedures inside Dynamics is somethimes useful somethimes, for better events' controlevents handling, but from what you are describingnothing fancy is going on here. Thus it is better to moveschedule calculations in a more stable way, by moving the Grid generation outside Dynamic.

Your exporting procedure clearly expects myplots to have an up to date value with respect to expr.

expr=values;
Export["file.png", myplots];

So keeping myplots=Grid[...] in a Dynamic is not a stable solution.

Why it is better to keep "procedures" outside and use DynamicDynamics only for displaying things?

  • You can force FinishDynamic[] before the Export but if your Dynamic[myplots...] is not currently visible on a screen it won't be updated and assigned anyway.

  • ref: "FinishDynamic[] does not return until all Dynamic objects are updated and displayed. " - all, sound"all" sounds like an overkill for our purpose, doesn't it?

  • Dynamic[ myplots=Grid[...] ] requests this Grid calculation over the PreemptiveLink, it will timeout after DynamicEvaluationTimeout (6 seconds by default) and it will freeze other FrontEnd activities till it is finished.

Which isn't critical since you can icrease the timeout limit or use SunchronousUpdatingSynchronousUpdating ->False> False (runs on the MainLink), but why complicate things.

If something is not clear I'm encouraging you to lookup those symbols in Help and read Advanced Dynamic Functionality tutorial (and related)

What I'd change is the following:

  • create a plot updating procedure (for flexibility and readability)

      updatePlot[]:= (myplots=Grid[...]);
    

You can put it in DynamicModule's Initialization.

  • includeinsert it in the exporting procedure

      expr=values;
      updatePlot[];
      Export["file.png", myplots];
    
  • change your Dynamic content:

      Dynamic[expr;myplots, TrackedSymbols:>{expr}]
    
  • additionaly you can introduce progress state variable to show a ProgressIndicator instead of myPlots before they are recalculated. Analogously to Palette button with progress bar, which is nice from user perspective.

Notice expr;, even though it is mentioned in TrackedSymbols it has to be explicitly stated in Dynamic's body to be properly tracked.

  • additionaly you can introduce progress state variable to show a ProgressIndicator instead of myPlots before they are recalculated. Analogously to Palette button with progress bar, which is nice from user perspective.

I think you should change your setup a little bit. Including procedures inside Dynamics is somethimes useful, for better events' control, but from what you are describing it is better to move the Grid generation outside.

Your exporting procedure clearly expects myplots to have an up to date value with respect to expr.

expr=values;
Export["file.png", myplots];

So keeping myplots=Grid[...] in Dynamic is not a stable solution.

Why it is better to keep "procedures" outside and use Dynamic only for displaying things?

  • You can force FinishDynamic[] before the Export but if your Dynamic[myplots...] is not currently visible on a screen it won't be updated and assigned anyway.

  • ref: "FinishDynamic[] does not return until all Dynamic objects are updated and displayed. " - all, sound like an overkill for our purpose, doesn't it?

  • Dynamic[ myplots=Grid[...] ] requests this Grid calculation over the PreemptiveLink, it will timeout after DynamicEvaluationTimeout (6 seconds by default) and it will freeze other FrontEnd activities till it is finished.

Which isn't critical since you can icrease the timeout limit or use SunchronousUpdating->False (runs on the MainLink), but why complicate things.

If something is not clear I'm encouraging you to lookup those symbols and read Advanced Dynamic Functionality tutorial (and related)

What I'd change is the following:

  • create plot updating procedure (for flexibility and readability)

      updatePlot[]:= (myplots=Grid[...]);
    

You can put it in DynamicModule's Initialization.

  • include it in the exporting procedure

      expr=values;
      updatePlot[];
      Export["file.png", myplots];
    
  • change your Dynamic content:

      Dynamic[expr;myplots, TrackedSymbols:>{expr}]
    
  • additionaly you can introduce progress state variable to show a ProgressIndicator instead of myPlots before they are recalculated. Analogously to Palette button with progress bar, which is nice from user perspective.

Notice expr;, even though it is mentioned in TrackedSymbols it has to be explicitly stated in Dynamic's body to be properly tracked.

I think you should change your setup a little bit. 

Including procedures inside Dynamics is useful somethimes, for better events handling, but nothing fancy is going on here. Thus it is better schedule calculations in a more stable way, by moving the Grid generation outside Dynamic.

Your exporting procedure clearly expects myplots to have an up to date value with respect to expr.

expr=values;
Export["file.png", myplots];

So keeping myplots=Grid[...] in a Dynamic is not a stable solution.

Why it is better to keep "procedures" outside and use Dynamics only for displaying things?

  • You can force FinishDynamic[] before the Export but if your Dynamic[myplots...] is not currently visible on a screen it won't be updated and assigned anyway.

  • ref: "FinishDynamic[] does not return until all Dynamic objects are updated and displayed. " - "all" sounds like an overkill for our purpose, doesn't it?

  • Dynamic[ myplots=Grid[...] ] requests this Grid calculation over the PreemptiveLink, it will timeout after DynamicEvaluationTimeout (6 seconds by default) and it will freeze other FrontEnd activities till it is finished.

Which isn't critical since you can icrease the timeout limit or use SynchronousUpdating -> False (runs on the MainLink), but why complicate things.

If something is not clear I'm encouraging you to lookup those symbols in Help and read Advanced Dynamic Functionality tutorial (and related)

What I'd change is the following:

  • create a plot updating procedure (for flexibility and readability)

      updatePlot[]:= (myplots=Grid[...]);
    

You can put it in DynamicModule's Initialization.

  • insert it in the exporting procedure

      expr=values;
      updatePlot[];
      Export["file.png", myplots];
    
  • change your Dynamic content:

      Dynamic[expr;myplots, TrackedSymbols:>{expr}]
    

Notice expr;, even though it is mentioned in TrackedSymbols it has to be explicitly stated in Dynamic's body to be properly tracked.

  • additionaly you can introduce progress state variable to show a ProgressIndicator instead of myPlots before they are recalculated. Analogously to Palette button with progress bar, which is nice from user perspective.
added 282 characters in body
Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751

I think you should change your setup a little bit. Including procedures inside Dynamics is somethimes useful, for better events' control, but from what you are describing it is better to move the Grid generation outside.

Your exporting procedure clearly expects myplots to have an up to date value with respect to expr.

expr=values;
Export["file.png", myplots];

So keeping myplots=Grid[...] in Dynamic is not a stable solution.

Why it is better to keep "procedures" outside and use Dynamic only for displaying things?

  • You can force FinishDynamic[] before the Export but if your Dynamic[myplots...] is not currently visible on a screen it won't be updated and assigned anyway.

  • ref: "FinishDynamic[] does not return until all Dynamic objects are updated and displayed. " - all, sound like an overkill for our purpose, doesn't it?

  • Dynamic[ myplots=Grid[...] ] requests this Grid calculation over the PreemptiveLink, it will timeout after DynamicEvaluationTimeout (6 seconds by default) and it will freeze other FrontEnd activities till it is finished.

Which isn't critical since you can icrease the timeout limit or use SunchronousUpdating->False (runs on the MainLink), but why complicate things.

If something is not clear I'm encouraging you to lookup those symbols and read Advanced Dynamic Functionality tutorial (and related)

What I'd change is the following:

  • create plot updating procedure (for flexibility and readability)

      updatePlot[]:= (myplots=Grid[...]);
    

You can put it in DynamicModule's Initialization.

  • include it in the exporting procedure

      expr=values;
      updatePlot[];
      Export["file.png", myplots];
    
  • change your Dynamic content:

      Dynamic[expr;myplots, TrackedSymbols:>{expr}]
    
  • additionaly you can introduce progress state variable to show a ProgressIndicator instead of myPlots before they are recalculated. Analogously to Palette button with progress bar, which is nice from user perspective.

Notice expr;, even though it is mentioned in TrackedSymbols it has to be explicitly stated in Dynamic's body to be properly tracked.

I think you should change your setup a little bit. Including procedures inside Dynamics is somethimes useful, for better events' control, but from what you are describing it is better to move the Grid generation outside.

Your exporting procedure clearly expects myplots to have an up to date value with respect to expr.

expr=values;
Export["file.png", myplots];

So keeping myplots=Grid[...] in Dynamic is not a stable solution.

Why it is better to keep "procedures" outside and use Dynamic only for displaying things?

  • You can force FinishDynamic[] before the Export but if your Dynamic[myplots...] is not currently visible on a screen it won't be updated and assigned anyway.

  • ref: "FinishDynamic[] does not return until all Dynamic objects are updated and displayed. " - all, sound like an overkill for our purpose, doesn't it?

  • Dynamic[ myplots=Grid[...] ] requests this Grid calculation over the PreemptiveLink, it will timeout after DynamicEvaluationTimeout (6 seconds by default) and it will freeze other FrontEnd activities till it is finished.

Which isn't critical since you can icrease the timeout limit or use SunchronousUpdating->False (runs on the MainLink), but why complicate things.

If something is not clear I'm encouraging you to lookup those symbols and read Advanced Dynamic Functionality tutorial (and related)

What I'd change is the following:

  • create plot updating procedure (for flexibility and readability)

      updatePlot[]:= (myplots=Grid[...]);
    

You can put it in DynamicModule's Initialization.

  • include it in the exporting procedure

      expr=values;
      updatePlot[];
      Export["file.png", myplots];
    
  • change your Dynamic content:

      Dynamic[expr;myplots, TrackedSymbols:>{expr}]
    

Notice expr;, even though it is mentioned in TrackedSymbols it has to be explicitly stated in Dynamic's body to be properly tracked.

I think you should change your setup a little bit. Including procedures inside Dynamics is somethimes useful, for better events' control, but from what you are describing it is better to move the Grid generation outside.

Your exporting procedure clearly expects myplots to have an up to date value with respect to expr.

expr=values;
Export["file.png", myplots];

So keeping myplots=Grid[...] in Dynamic is not a stable solution.

Why it is better to keep "procedures" outside and use Dynamic only for displaying things?

  • You can force FinishDynamic[] before the Export but if your Dynamic[myplots...] is not currently visible on a screen it won't be updated and assigned anyway.

  • ref: "FinishDynamic[] does not return until all Dynamic objects are updated and displayed. " - all, sound like an overkill for our purpose, doesn't it?

  • Dynamic[ myplots=Grid[...] ] requests this Grid calculation over the PreemptiveLink, it will timeout after DynamicEvaluationTimeout (6 seconds by default) and it will freeze other FrontEnd activities till it is finished.

Which isn't critical since you can icrease the timeout limit or use SunchronousUpdating->False (runs on the MainLink), but why complicate things.

If something is not clear I'm encouraging you to lookup those symbols and read Advanced Dynamic Functionality tutorial (and related)

What I'd change is the following:

  • create plot updating procedure (for flexibility and readability)

      updatePlot[]:= (myplots=Grid[...]);
    

You can put it in DynamicModule's Initialization.

  • include it in the exporting procedure

      expr=values;
      updatePlot[];
      Export["file.png", myplots];
    
  • change your Dynamic content:

      Dynamic[expr;myplots, TrackedSymbols:>{expr}]
    
  • additionaly you can introduce progress state variable to show a ProgressIndicator instead of myPlots before they are recalculated. Analogously to Palette button with progress bar, which is nice from user perspective.

Notice expr;, even though it is mentioned in TrackedSymbols it has to be explicitly stated in Dynamic's body to be properly tracked.

Source Link
Kuba
  • 137.7k
  • 13
  • 289
  • 751
Loading