multi app designer wait function
10 views (last 30 days)
Show older comments
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 Comment
Answers (1)
Nivedita
on 5 Jan 2024
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:
- GUI1 has a button (to open GUI2) and a numeric edit field, and GUI2 has a button (to close GUI2).
- Upon opening GUI2, GUI1 pauses unless GUI2 is closed.
- The button in GUI1 is disabled when pushed and is re-enabled when GUI2 is closed to avoid opening multiple instances of GUI2.
- 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:
- Create multiwindow apps in app designer: https://www.mathworks.com/help/matlab/creating_guis/creating-multiwindow-apps-in-app-designer.html
- "uiwait" : https://www.mathworks.com/help/matlab/ref/uiwait.html
- "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!
0 Comments
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!