multi app designer wait function

9 次查看(过去 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 个)

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