multi app designer wait function

조회 수: 8 (최근 30일)
Jae-Hee Park
Jae-Hee Park 2022년 5월 27일
답변: Nivedita 2024년 1월 5일
Hi there!
I am here to find answer!
I make a app with app designer which have multi apps.
When I start the App, GUI1 is appeared. Then when I want to change parameters so I click the button then GUI2 is appeared.
I want to pause GUI1 until GUI2 is closed.
How can I do this?
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 5월 27일
https://www.mathworks.com/help/matlab/ref/waitfor.html or uiwait()

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

답변 (1개)

Nivedita
Nivedita 2024년 1월 5일
Hello Jae-Hee Park,
I understand that you want to pause GUI1 until GUI2 is closed. You can do this by using the "uiwait" and "uiresume" functions.
I created a very simple multi window app, where:
  1. GUI1 has a button (to open GUI2) and a numeric edit field, and GUI2 has a button (to close GUI2).
  2. Upon opening GUI2, GUI1 pauses unless GUI2 is closed.
  3. The button in GUI1 is disabled when pushed and is re-enabled when GUI2 is closed to avoid opening multiple instances of GUI2.
  4. The edit field gets populated when GUI2 is closed.
Below attached are the button pushed callback functions of both the apps:
%% Code from GUI1
% Button pushed function: OpenGUI2Button
function OpenGUI2ButtonPushed(app, event)
% Disable the button to prevent opening multiple instances of GUI2
app.OpenGUI2Button.Enable = "off";
%Create an instance of GUI2
gui2 = GUI2;
% Pause interaction with GUI1 until GUI2 is closed
uiwait(gui2.UIFigure);
% Re-enable the button after GUI2 is closed
app.OpenGUI2Button.Enable = "on";
%Resume the next lines of code in GUI1 after GUI2 is closed
app.EditField.Value = 10;
end
%% Code from GUI2
% Button pushed function: CloseGUI2Button
function CloseGUI2ButtonPushed(app, event)
% Resume GUI1
uiresume(app.UIFigure);
% Close GUI2
delete(app);
end
You can refer to the following links for further understanding:
  1. Create multiwindow apps in app designer: https://www.mathworks.com/help/matlab/creating_guis/creating-multiwindow-apps-in-app-designer.html
  2. "uiwait" : https://www.mathworks.com/help/matlab/ref/uiwait.html
  3. "uiresume" : https://www.mathworks.com/help/matlab/ref/uiresume.html
Also attaching another MATLAB answer link which shows how you can disable different components in an app:
I have attached the MLAPP files of GUI1 and GUI2 for your reference.
I hope you find these resources useful!

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by