Opening a GUI from another GUI with a delay in App Designer
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have to open a second GUI2 from a main GUI1. I would like to open the GUI2 with a delay. I used the timer in this way: t = timer('TimerFcn', @(~,~) uiwait(app2.UIFigure), 'StartDelay', 5); start(t); and pause(5) but the second GUI is open immediatley. The istruction to open the GUI2 is uiwait(app2.UIFigure). In documentation about uiwait(app2.UIFigure) I have seen that I can use uiwait(app2.UIFigure, timeout) but also this method is not working.
I have to open the GUI2 in a loop. This is the code
for i=1:30
% do something
uiwait(app2.UIFigure)
% do something
I used also this:
time_await = 5; % Time await in seconds
t0 = tic;
% Start timer
while toc(t0) < time_await
drawnow;
end
No solution is working and I don't know how to open the second GUI with a delaly
0 Kommentare
Antworten (2)
Rik
am 10 Apr. 2023
I suspect the new GUI is opened because Matlab is unable to store the anonymous function without creating that new GUI.
What you can do is write a wrapper function that opens the second GUI. That way you can use the timer to run that function with a delay and all should be well.
0 Kommentare
Amit Dhakite
am 10 Apr. 2023
Bearbeitet: Amit Dhakite
am 10 Apr. 2023
Hi Tania,
As per my understanding, you would like to open a second GUI2 from main GUI1, with some x seconds delay.
You can use pause() function to delay the execution of the code. Here is an example code for opening a second GUI2 from GUI1 after a delay of 5 seconds:
% Button pushed function: Callback in which you want to open second GUI
function buttonPushed(app, event)
% Introduce a delay of 5 seconds
pause(5);
% Create an instance of the second GUI
secondGUI = GUI2;
% Show the second GUI
secondGUI.UIFigure.Visible = 'on';
end
Please note that you can customize the above code to meet your specific requirements.
For further information, kindly refer to the following links.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Dialog Boxes finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!