Adding a progress bar in App Designer inside a callback

20 ビュー (過去 30 日間)
Atharva Sule
Atharva Sule 2022 年 2 月 24 日
コメント済み: Rik 2022 年 2 月 25 日
I'm trying to design an app where multiple models are simulated at the press of a single button. I've added the entire code for all models within the callback for the said button. I also want to display a progress bar that displays which model is being executed (and its progress). Where should I add the code for the progress bar? I tried adding the code in the same callback function but the progress bar shows up after the entire callback has been executed. Thanks in advance.
  3 件のコメント
Atharva Sule
Atharva Sule 2022 年 2 月 25 日
Thanks a lot, @Rik! That worked.
Rik
Rik 2022 年 2 月 25 日
You're welcome, I expanded my comment and posted is as an answer. That should increase the visibility for future users with a similar issue.

サインインしてコメントする。

採用された回答

Rik
Rik 2022 年 2 月 25 日
To increase performance, Matlab does not automatically update graphics elements on the screen after a function call that modified/created it. This allows creation and modification of object to be processed together, instead of one after the other.
Whenever Matlab stops execution (e.g. after a pause or when finishing the execution of a callback) it will flush the queue of graphics interactions. This not only includes updating graphics, but also triggering new callbacks. You can force this flushing in two ways:
  1. Call pause with a tiny interval (to avoid the wait time to harm performance too much).
  2. Call drawnow directly.
Usually there is no need to do this and the automatic methods work well enough, but if you want to ensure your user sees a particular change, the drawnow function is there to facilitate this.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by