更新mathematica中的进度条

发布于 2024-10-06 15:55:55 字数 242 浏览 0 评论 0原文

在计算过程中,我会更新进度条的值以通知用户计算的进度。

不幸的是,我无法执行此操作,因为当我调用 SetPropertyValue 函数时,

ref@SetPropertyValue[{"bar", "value"}, 70];

该值不会更新。

我以这种方式获得参考

ref = GUIRun[mainWindow];

during the computation I would update the value of progress bar to notify to the user the progress of the computation.

Unfortunately I'm not able to do this because when I call SetPropertyValue function

ref@SetPropertyValue[{"bar", "value"}, 70];

the value isn't updated.

I obtain ref in this way

ref = GUIRun[mainWindow];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

薄荷港 2024-10-13 15:55:55

对于 Mathematica 6 或更高版本,请尝试使用 Monitor 和 ProgressIndicator 而不是旧的 GUIKit 包:

With[{count = 1000}, 
 Monitor[Do[Pause[0.01];, {i, count}], 
  ProgressIndicator[Dynamic[i/count]]]]

With Mathematica 6 or later try using Monitor and ProgressIndicator instead of the older GUIKit package:

With[{count = 1000}, 
 Monitor[Do[Pause[0.01];, {i, count}], 
  ProgressIndicator[Dynamic[i/count]]]]
别低头,皇冠会掉 2024-10-13 15:55:55

这只是@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
];

如果你想将进度指示器保存为动画 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}]  

结果是:

替代文字

This is just an extension to @ragfield's answer.

If you want to represent bounded and unbounded magnitudes, you colud do something along these lines:

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
];

If you want to save the progress indicators as an animated gif for presententations and the such, you could modify it a bit:

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}]  

and the result is:

alt text

娜些时光,永不杰束 2024-10-13 15:55:55

执行

Needs["GUIKit`"];

您是否记得在开始使用 GUIKit 之前 ?如果不是,您的命令将不会执行,因为它们是未知的。如果您在开始使用 GUIKit 后加载它,请不要忘记它的某些符号可能会被您无意中定义的符号所遮蔽。

Did you remember to execute

Needs["GUIKit`"];

before starting to use the GUIKit ? If not your commands won't execute, because they are not known. If you load the GUIKit after you start using it, don't forget that some of its symbols may be shadowed by the symbols you have inadvertently defined.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文