App Designer: Display text before executing

12 ビュー (過去 30 日間)
Matt Falcy
Matt Falcy 2019 年 5 月 6 日
コメント済み: Matt Falcy 2019 年 5 月 7 日
This is relatively simple: When a user pushes a button in App Designer, I want them to see a message saying that the operation is execuing because it takes a few minutes to complete. In the example below, the "Working..." message is not displayed prior executing the loop, thus the user only sees "Done" when the operation is over. I suspect that I need the function to display the "Working" text and then call the other, time consuming function, but it is not clear how I do this inside App Designer. Thanks.
function buttonpush(app,event)
app.myEditField.Value= 'Working...'
for i =1:100
x[i]=stuff
end
app.myEditField.Value = 'Done'
end

採用された回答

Kojiro Saito
Kojiro Saito 2019 年 5 月 7 日
One way is to pause a bit (for exapmle, 0.01 second) in order to display the text before doing long-time operation.
function buttonpush(app,event)
app.myEditField.Value= 'Working...';
pause(0.01)
for i =1:100
x[i]=stuff
end
app.myEditField.Value = 'Done';
end
Or, you can use progress message dialog (uiprogressdlg).
function buttonpush(app,event)
d = uiprogressdlg(app.UIFigure,'Title','Progress', 'Indeterminate','on');
d.Message = 'Working...';
for i =1:100
x[i]=stuff
end
d.Message = 'Done';
close(d)
end

その他の回答 (1 件)

Jan
Jan 2019 年 5 月 7 日
This is a job for drawnow. Insert it after modifying the contents of the window to give Matlab the chance to update the display.
  1 件のコメント
Matt Falcy
Matt Falcy 2019 年 5 月 7 日
I tried all three solutions and they all worked great. Thank you Kojiro and Jan!

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

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by