Collecting User Inputs With Multiple GUI Windows?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have a Matlab simulation and I would like to create multiple GUI windows to obtain all the user inputs where once each window is completed, the user can proceed to the next window using a toggle button and once the last window is completed, the user can execute the simulation.
How can this be done using the GUIDE tool? I know how to create the GUIs and extract the data from the GUIs as input. My main problem lies with using two or more separate GUI figures subsequently for the same .m simulation file. Any guidance would be appreciated.
0 Kommentare
Akzeptierte Antwort
Ryan
am 12 Aug. 2014
You can call each GUI function within the script file and wait for the user to close the GUI that is open to proceed to the next one.
The way I do it is open a new GUI and edit the default script as follows:
Within the filename_OpeningFcn delete the "%" in the last line of the function so the last line looks like this:
uiwait(handles.figure1)
Then create a CloseRequestFcn and replace "delete(hObject)" with:
if isequal(get(hObject,'waitstatus'),'waiting')
uiresume(hObject);
else
delete(hObject);
end
Then use exit within the call function of your pushbutton and it will close when you push it and move on to the next GUI if you call them in your script like this:
GUI1();
GUI2();
...etc
Weitere Antworten (2)
Geoff Hayes
am 12 Aug. 2014
Another alternative would be to create one GUI with multiple uipanels that become visible (or invisible) as you cycle through the "wizard" steps. Each uipanel is located at the same position (and has the same width and height) as all others, but when the GUI starts, only uipanel1 is visible and all others are invisible. Callbacks for the next and previous buttons could determine which panels to hide and which one to show.
In a very simple example could be a GUI with two panels and three buttons (outside of the panels) near the bottom of the GUI labelled Previous, Next, and Finish. The first and last button are disabled if on the first panel. The second button is disabled if on the second panel. The callbacks for the previous and next buttons could look like
function pushbutton1_Callback(hObject, eventdata, handles)
% code for the previous pushbutton
set(handles.uipanel2,'Visible','off');
set(handles.uipanel1,'Visible','on');
set(handles.pushbutton3,'Enable','off');
set(handles.pushbutton2,'Enable','on');
set(handles.pushbutton1,'Enable','off');
function pushbutton2_Callback(hObject, eventdata, handles)
% code for the next pushbutton
set(handles.uipanel1,'Visible','off');
set(handles.uipanel2,'Visible','on');
set(handles.pushbutton3,'Enable','on');
set(handles.pushbutton2,'Enable','off');
set(handles.pushbutton1,'Enable','on');
As long as you don't have too many panels, and each panel doesn't become too busy with widgets, this is an option. And with all data (user choices) available within the one GUI, you don't have to worry about passing data back and forth between apps.
0 Kommentare
Joakim Magnusson
am 12 Aug. 2014
Maybe you can make tabs or a "next" button on each window and for example when you press next you open another gui and close the previous one? And pass the user input between the gui.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!