How to indicate if the program is processing in app designer?

My program sometimes takes 10-20 seconds to run. The problem is that I don't have any way to see if the program is processing or it just hit a bug.
Is there a way in app designer to let the user know that the program is running after the they've pushed the button?
function CalculateButtonPushed(app, event)
x=app.XEditField.Value;
y=app.YEditField.Value;
z=app.ZEditField.Value;
I=app.CurrentAEditField.Value;
[Bx,By,Bz] = Magnetic_field_solenoid_cartesian1(app,x,y,z,I);
app.BxmGsEditField.Value=Bx;
app.BymGsEditField.Value=By;
app.BzmGsEditField.Value=Bz;
end

1 件のコメント

Adam
Adam 2020 年 1 月 31 日
Put some text on the GUI? I created a BusyCursor class that I use in regular figure and GUIDE apps. No idea if it works with AppDesigner as I haven't tried, but essentially all it does is change the cursor to the Windows busy cursor.
In other situations I use a progress bar (one from the File Exchange, but the builtin waitbar works too).
and in other cases I simply put a small place on my GUI for info text and change it to 'Processing...' and then to 'Done' or something similar once processing completes.

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

回答 (1 件)

Mohammad Sami
Mohammad Sami 2020 年 1 月 31 日

0 投票

Use the function dlg = uiprogressdlg(app.UIFigure); See documentation for all available options with the function.

6 件のコメント

sepand soltani
sepand soltani 2020 年 1 月 31 日
This doesn't really suit my need. I don't want a "progress bar". I just need an indicator with two states: "calculating" and "done" and preferably it's implemented in the GUI instead of a pop up screen.
Adam
Adam 2020 年 1 月 31 日
Just implement it then! What is causing the problem?
sepand soltani
sepand soltani 2020 年 1 月 31 日
function CalculateButtonPushed(app, event)
% app.ProcessIndicator is a text area
app.ProcessIndicator.Value='Processing...';
x=app.XEditField.Value;
y=app.YEditField.Value;
z=app.ZEditField.Value;
I=app.CurrentAEditField.Value;
[Bx,By,Bz] = Magnetic_field_solenoid_cartesian1(app,x,y,z,I);
app.BxmGsEditField.Value=Bx;
app.BymGsEditField.Value=By;
app.BzmGsEditField.Value=Bz;
Bt=sqrt(Bx^2+By^2+Bz^2);
app.BtotalmGsEditField.Value=Bt;
app.ProcessIndicator.Value='Done!';
end
I tried this but it only shows the "Done!".
Adam
Adam 2020 年 1 月 31 日
Try putting a
drawnow
or
pause( 0.1 )
instruction after
app.ProcessIndicator.Value='Processing...';
sepand soltani
sepand soltani 2020 年 1 月 31 日
Worked flawlessly!! Thanks.
How to indicate if the process end

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

カテゴリ

ヘルプ センター および File ExchangeApp Building についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by