Sharing Data between two GUIs
1 次查看(过去 30 天)
显示 更早的评论
I basically have one main GUI that is calling for a smaller GUI which simply contains clear check boxes. What I want to do is be able to obtain the data informing me which check box is checked and which one is not in my main GUI. I have tried the following already:
function progselec_opt_SelectionChangeFcn(hObject,eventdata)
%retrieve GUI data, i.e. the handles structure
handles = guidata(hObject);
set(handles.step1txt,'BackgroundColor',[1 0 0]);
set(handles.updatestatus_txt,'BackgroundColor',[1 0 0],'String','UPDATE REQUIRED');
switch get(eventdata.NewValue,'Tag')
case 'allprog_radbut'
case 'specprog_radbut'
acoustic_programs %Summons second GUI
end
acoustic_programsFigureHandle = acoustic_programs;
acoustic_programsData = guidata(acoustic_programsFigureHandle);
get(acoustic_programsData.quetzsat_checkbx,'Value') %Get the value of one of the check boxes
guidata(hObject, handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This however gives the value of the checkbox before it was even checked, in other words my output is only zero. Please help
0 个评论
采纳的回答
Walter Roberson
2011-9-27
Getting the Tag of eventdata.NewValue only makes sense if this callback is the callback of a button-group.
If the NewValue Tag is 'specproc_radbut' then you run acoustic_programs within the switch. And then, either way, after the switch, you run acoustic_programs again, this time recording the handle. Depending on how acoustic_programs is coded, the GUI for the first run might not be the same gui as for the second run, or running again could re-initialize the boxes.
Note: your code does not change any value in handles, so it does not need to store handles with your final guidata() call.
3 个评论
Walter Roberson
2011-9-27
In the code you have, you launch the second gui, but you do not give any time for the user to do anything before you check the status of the checkbox.
Perhaps you would like to
waitfor(acoustic_programsData.quetzsat_checkbx,'Value')
http://www.mathworks.com/help/techdoc/ref/waitfor.html
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!