필터 지우기
필터 지우기

Wait until object is rendered in App Designer

조회 수: 13 (최근 30일)
Christof
Christof 2024년 6월 9일
댓글: Mario Malic 2024년 6월 9일
Hello together,
I'm using the loading screen as desribed here, while my data is loaded.
The loading screen is closed, when the last function has finished. But no objects are rendered at this moment.
I'm creating a lot of buttons and edit fields programatically. But they are rendered very late, after the functions are already finished.
How to wait with closing the loading screen, until everything is rendered (or nearly at least)?
Thanks in advance!
Christof
  댓글 수: 1
Mario Malic
Mario Malic 2024년 6월 9일
More info would be helpful about interactions of these functions and UI components. I don't think that there is some reliable way to wait for the components to show up on the screen. After creating the last component, I would suggest to use pause and drawnow.

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

채택된 답변

Christof
Christof 2024년 6월 9일
편집: Christof 2024년 6월 9일
Perfect Mario! It worked with drawnow at the end of the loop for creating buttons.
Thank you very much:)
Here's a snippet.
%...Loop for creatng ~250 buttons...
% Default buttons into MU analog tab - no signal. Date, Time, Time [s], Event
else
app.Logs(app.Log).Variables{2, i} = uibutton(app.MUTab, 'state'); %Creating a Default Button in MU Analog TAB
app.Logs(app.Log).Variables(3, i) = num2cell(2);
app.Logs(app.Log).Variables(4, i) = {'MUTab'};
app.Logs(app.Log).Variables{2, i}.Tag = 'noPlot';
end
app.Logs(app.Log).Variables{2, i}.Position = A; %Giving the Button a position
app.Logs(app.Log).Variables{2, i}.Text = app.Logs(app.Log).Variables(1, i); %Giving the Button it's Text
if i == 2 || i == 3 || i == 4 % Show buttons pushed for the first x columns
app.Logs(app.Log).Variables{2, i}.Value = 1; % Button activated
app.Logs(app.Log).Variables{2, i}.BackgroundColor = [0.75 0.97 0.75]; % Light green for activated state
end
% Random colors per variable for plot
RandomColor = rand(1, 3);
if ((RandomColor(1) > 0.9) && (RandomColor(2)) > 0.9 && (RandomColor(3) > 0.9))
RandomColor = RandomColor - [0.1 0.1 0.1]; % Shift darker if too bright
elseif ((RandomColor(1) < 0.1) && (RandomColor(2) < 0.1) && (RandomColor(3) < 0.1))
RandomColor = RandomColor + [0.1 0.1 0.1]; % Shift lighter if too dark
end % Put random color into button user data
app.Logs(app.Log).Variables{2, i}.UserData(1,2:4) = RandomColor(1:3);
app.Logs(app.Log).Variables{2, i}.ValueChangedFcn = @app.DataButtonPress; %Callback function for variable buttons
app.Logs(app.Log).Variables{2, i}.UserData(1,1) = i; % Put Nr of Variable in Userdata of button
posEdit = A;
posEdit(3) = 24; % Position for Editfield for this button/variable
posEdit(1) = A(3) - A(1) +1 ;
app.Logs(app.Log).Variables{5, i}.Position = posEdit;
app.Logs(app.Log).Variables{5, i}.Value = 0;
A(2) = A(2) -21; %Position change for the next Button
end
% forces rendering before going on(?)
drawnow
end

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by