필터 지우기
필터 지우기

Image component not updated in AppDesigner GUI

조회 수: 3 (최근 30일)
Johan Melander
Johan Melander 2023년 2월 23일
댓글: Johan Melander 2023년 2월 23일
In an AppDesigner App (GUI) I have a number of Axes and numeric input fields. I also have a button in the GUI that I press when to start the calculations, based in the input fields, and eventually to plot the results. Sometimes this takes some time and I would like to indicate the "busy" state in the GUI.
I have added an Image component in the GUI that resulted in the below code in the Component Initialization section;
% Create StatusImage
app.StatusImage = uiimage(app.UIFigure);
app.StatusImage.Position = [1529 591 107 52];
In the "startupFcn(app)" i have added the following code (where 'busyImage' and 'idleImage' are Private properties.;
app.busyImage = imread('Busy.PNG');
app.idleImage = imread('Idle.PNG');
In the "Calculate"-button call-back I have the following code;
function UpdateButtonPushed(app, event)
app.StatusImage.ImageSource = app.busyImage;
doCalculations(app);
updatePositionSweepPlot(app);
app.StatusImage.ImageSource = app.idleImage;
end
The result is that the Image is not changed at all when pressing the "button". However, when running this in the debugger the image is updated. How do I solve this?

채택된 답변

Simon Chan
Simon Chan 2023년 2월 23일
Add drawnow after the line updated the image.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by