pAk*_*Y88 6 wolfram-mathematica progress-bar
在计算过程中,我会更新进度条的值,以通知用户计算的进度.
不幸的是,当我调用SetPropertyValue函数时,我无法做到这一点
ref@SetPropertyValue[{"bar", "value"}, 70];
Run Code Online (Sandbox Code Playgroud)
该值未更新.
我以这种方式获得了参考
ref = GUIRun[mainWindow];
Run Code Online (Sandbox Code Playgroud)
使用Mathematica 6或更高版本尝试使用Monitor和ProgressIndicator而不是旧的GUIKit包:
With[{count = 1000},
Monitor[Do[Pause[0.01];, {i, count}],
ProgressIndicator[Dynamic[i/count]]]]
Run Code Online (Sandbox Code Playgroud)
这只是@ ragfield答案的延伸.
如果你想表示有界和无界的大小,你就会沿着这些方向做一些事情:
Clear["Global`*"];
count = 0; inRange = 0; i = 0; sumTgt = 10^5
Monitor[
While[count < sumTgt,
If[.14 < (rand = RandomReal[]) < .15, inRange++];
count += rand;
]
, {{"SumTillNow", ProgressIndicator[count, {0, sumTgt} ],count},
{"InRange", ProgressIndicator[inRange, Indeterminate],inRange}}
// MatrixForm
];
Run Code Online (Sandbox Code Playgroud)
如果要将进度指示器保存为演示文稿的动画gif等,可以稍微修改一下:
count = 0; inRange = 0; i = 0; sumTgt = 10^4
Monitor[
While[count < sumTgt,
If[.14 < (rand = RandomReal[]) < .15, inRange++];
count += rand;
]
, a[++i] = Grid[
{{"SumTillNow", ProgressIndicator[count, {0, sumTgt}],count},
{"InRange", ProgressIndicator[inRange, Indeterminate],inRange + 0.}},
Frame -> All, Alignment -> {{Left, Center, Right}},
ItemSize -> {{Automatic, Automatic, 8}}];
];
Export["c:\Anim.gif", Table[a[j]//MatrixForm, {j, i}],"DisplayDurations"->{.3}]
Run Code Online (Sandbox Code Playgroud)
结果是:

你记得执行吗
Needs["GUIKit`"];
Run Code Online (Sandbox Code Playgroud)
在开始使用 GUIKit 之前?如果不是,您的命令将不会执行,因为它们是未知的。如果您在开始使用 GUIKit 后加载它,请不要忘记它的某些符号可能会被您无意中定义的符号所遮蔽。
| 归档时间: |
|
| 查看次数: |
2571 次 |
| 最近记录: |