我在使用 Button
导出文件时遇到问题。这段简单的代码只是创建一些数据,即我想要导出为动画 .gif 的 Graphics
列表。
foo = Graphics /@
Table[{GrayLevel[RandomReal[]], Disk[{i, j}, 0.5]},
{k, 50}, {i, 10}, {j, 10}];
现在使用 Export["foo.gif", foo]
导出 foo
可以按预期工作(尽管这需要相当长的时间)。
但是,当我创建一个 Button
时,例如使用 Button["Export!", Export["foo.gif", foo]]
,单击按钮会导致 Mathematica 卡住一段时间。之后,评估似乎停止了,但什么也没有导出。
我想使用该按钮在 Manipulate
环境中导出类似复杂的图形列表。
感谢您的帮助!
最佳答案
By default, button functions are evaluated on a preemptive link, which times out after 5 seconds
Use Method->"Queued" to evaluate button functions on the main link, which never times out:
Button["Export!", Export["c:\\test.gif", foo], Method -> "Queued"]
关于button - Mathematica : Exporting . 通过按钮的 gif 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12901209/