Clear Filters
Clear Filters

Wait until object is rendered in App Designer

16 views (last 30 days)
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 Comment
Mario Malic
Mario Malic on 9 Jun 2024
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.

Sign in to comment.

Accepted Answer

Christof
Christof on 9 Jun 2024
Edited: Christof on 9 Jun 2024
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

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!