How to call another GUI and let the rest code in GUI1 wait until GUI2 finishes executing?

2 ビュー (過去 30 日間)
Hello, I'm currently working on a GUI, which has a function of reading a certain column of an excel file. There are altogether two GUIs, GUI1 and GUI2. When users click the pushbutton 'read excel' in GUI1, GUI2 shows up, where users can input the column label(letter: A,B,C...) that needs to be read. By clicking the button 'OK' in GUI2 the results will be transferred back to GUI1 and display in a listbox in GUI1. But I have trouble with the proceeding sequence, so first here is my code(incomplete):
GUI1
function excel_reading_Callback(hObject, eventdata, handles)
global EX_RESULTS
assignin('base','EX_RESULTS',EX_RESULTS);
%open GUI2
GUI2
% fill in listbox with reading results
Fields_of_EX_Results=getappdata(GUI2,'Fields_of_EX_Results');
set(handles.results_listbox, 'String', fieldnames(Fields_of_EX_Results)); %%%Possible error, since Fields_of_EX_Results only exists after OK_Callback in GUI2 executes
GUI2
function OK_Callback(hObject, eventdata, handles)
global EX_RESULTS
%the users can input the column label in GUI2 and the corresponding column will be read
% and saved in a structure called EX_RESULTS
%by using setappdata and getappdata the results can be transferred back to GUI1
Now i got this error message, because in the excel_reading_Callback in GUI1, the 'set(handles.results_listbox....' can only execute after OK_Callback in GUI2 was finished executing and all results are store in EX_RESULTS. So how can I arrange the proceeding sequence of the code? So that the rest of code in GUI1 can wait until GUI2 is finishing executing? Or can I just use 'set' in GUI2 to set the results to listbox in GUI1?
THX in advance

採用された回答

Walter Roberson
Walter Roberson 2016 年 2 月 29 日
After calling GUI2, call uiwait() with no arguments. Then in GUI2, when it is ready, call uiresume() with the handle of GUI1
And try to avoid global!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by