Collecting User Inputs With Multiple GUI Windows?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Ryan
2014-8-12
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
更多回答(2 个)
Geoff Hayes
2014-8-12
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 个评论
Joakim Magnusson
2014-8-12
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!