Opening a GUI from another GUI with a delay in App Designer
조회 수: 7 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Rik
2023년 4월 10일
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
Amit Dhakite
2023년 4월 10일
편집: Amit Dhakite
2023년 4월 10일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Dialog Boxes에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!