Collecting User Inputs With Multiple GUI Windows?

5 ビュー (過去 30 日間)
Tyler
Tyler 2014 年 8 月 12 日
コメント済み: Tyler 2014 年 8 月 13 日
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.

採用された回答

Ryan
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
  1 件のコメント
Tyler
Tyler 2014 年 8 月 13 日
Thank you Ryan!! This is exactly what I was looking for!

サインインしてコメントする。

その他の回答 (2 件)

Geoff Hayes
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.

Joakim Magnusson
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.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by