Appdesigner: updating the value of Text area

조회 수: 10 (최근 30일)
Hisato Tanimoto
Hisato Tanimoto 2025년 2월 11일
이동: Stephen23 2025년 2월 12일
I want to show status of a function such as "running" and "finished" on a textarea like following code,
The start-button is pushed, then the calculantion function is started. And I expected the status(running/stopped) is updated on a text area, but it didn't work. ("running" condition did not show, but 'finished' did.)
function StartButtonPushed(app, event)
app.val = app.PromptTextArea.Value;
app.StartButton.Enable = "off";
app.statusTextArea.Value = "running";
calculation(app, app.val);
app.ResponseTextArea.Value = app.answer;
app.statusTextArea.Value = 'finished';
end
As a temporal solution, I placed "pause" like below. Do you have some smarter one?
function StartButtonPushed(app, event)
app.val = app.PromptTextArea.Value;
pause(1); % placed pause
app.StartButton.Enable = "off";
pause(1); % placed pause
app.statusTextArea.Value = "running";
pause(1); % placed pause
calculation(app, app.val);
app.ResponseTextArea.Value = app.answer;
app.statusTextArea.Value = 'finished';
end
  댓글 수: 1
Cris LaPierre
Cris LaPierre 2025년 2월 11일
I built a simple test app using the code you shared. It appears to work as you'd expect without needing to add pauses.
It may depend on what is happening in your calculation function. Try using drawnow instead of pause(1).

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2025년 2월 11일
function StartButtonPushed(app, event)
app.val = app.PromptTextArea.Value;
app.StartButton.Enable = "off";
app.statusTextArea.Value = "running";
drawnow() % <-----
calculation(app, app.val);
app.ResponseTextArea.Value = app.answer;
app.statusTextArea.Value = 'finished';
end
  댓글 수: 1
Hisato Tanimoto
Hisato Tanimoto 2025년 2월 12일
이동: Stephen23 2025년 2월 12일
Using drawnow went well. Thank you for your both answers.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by