Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Why does

DynamicModule[{grf, x}, 
 Panel[{Button["Export", Export["test.png", grf]], 
   Slider[Dynamic[x], {1, 4}], 
   grf = Dynamic[Graphics[{Line[{{1, x}, {x, 1}, {3, 2}}]}]]}]]

export properly in Mathematica but not Player Pro and

DynamicModule[{grf, x}, 
 Panel[{Button["Export", Export["test.png", grf]], 
   Slider[Dynamic[x], {1, 4}], 
   Dynamic[grf = Graphics[{Line[{{1, x}, {x, 1}, {3, 2}}]}]]}]]

export properly in both?

Thanks in advance.

share|improve this question

1 Answer 1

I cannot tell you, why Mathematica can handle your first case properly, while the Player doesn't, but I can tell you why your first example is wrong. Writing something like

grf = Dynamic[Graphics[....

is a bad idea, because, although you don't see it, the Dynamic head is still there. You can observe this by changing your example slightly

DynamicModule[{grf, x}, 
 Panel[{Button["Export", Print[InputForm[grf]]], 
   Slider[Dynamic[x], {1, 4}], 
   grf = Dynamic[Graphics[{Line[{{1, x}, {x, 1}, {3, 2}}]}]]}]]

When you now hit the button, then you see that you don't have a Graphics, you have a Graphics wraped in Dynamic. I guess the player cannot handle this.

You second example is correct, because you dynamicly set grf by wrapping the complete expression. Use the same print and you see that Export will get a correct Graphics object.

share|improve this answer
    
So grf = Dynamic[Graphics[... can be veryfied with Export["test.png", Setting @ grf]? –  Kuba Nov 22 '13 at 8:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.