Sharing Data between two GUIs

1 view (last 30 days)
John
John on 27 Sep 2011
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

Accepted Answer

Walter Roberson
Walter Roberson on 27 Sep 2011
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 Comments
Walter Roberson
Walter Roberson on 27 Sep 2011
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
John
John on 28 Sep 2011
Thank you so much for the help, waitfor was the command I needed. This is my first time making a GUI so learning alot. Thanks!

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!