필터 지우기
필터 지우기

Sharing Data between two GUIs

조회 수: 1 (최근 30일)
John
John 2011년 9월 27일
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

채택된 답변

Walter Roberson
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
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
John
John 2011년 9월 28일
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!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by