How to use one GUI to call many other GUI

1 view (last 30 days)
Hi, I'm trying to create a main GUI that gives options to user. Each options when pressed will lead users to another GUI. I only managed to do this when there is only 1 option in the main GUI using this simple code:
pushbutton1_Callback(option1);
option1;
However when i try to add more options to my main GUI it doesn't work. Below is the code:
pushbutton1_Callback(option1);
option1;
pushbutton2_Callback(option2);
option2;
pushbutton3_Callback(option3);
option3;
Using the above code, when pushbutton1 and pushbutton2 is pressed nothing happens. When pushbutton3 is pressed, all GUI for option1, option2, and option3 open in a infinite loop.
Hope if anyone have a solution to this. Thanks

Accepted Answer

Geoff Hayes
Geoff Hayes on 28 Sep 2016
Aloysius - what are the options? Do you have radio buttons that the user selects which is supposed to launch the new GUI, or do you have push buttons that the user presses to do the same? Please clarify and describe what the following code does (and where it is called from)
pushbutton1_Callback(option1);
option1;
The option1 variable (what type is this?) is passed to a pushbutton callback. Is this a custom callback that you have written? What does calling option1 on its own supposed to do?
Let's suppose that you have your main GUI, MyMainGui and your other GUI named MyOtherGui. If you have a push button on your main GUI that is supposed to launch the other GUI, then you would simply do
function pushbutton1_Callback(hObject,eventdata,handles)
MyOtherGui;
That's it. You would then do the same for the other GUIs that would launch in response to the user action.
  1 Comment
Aloysius Pallis
Aloysius Pallis on 29 Sep 2016
I have tried your way, and it worked like a charm.
To answer your question:
  1. Option1, option2, and option3 are simply the name of my other GUI's.
  2. I have several pushbuttons on my main GUI. Upon pressing each pushbutton, I want their respective other GUI to open up.
I have managed to solve it using your method. Thanks a bunch.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB 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!