Borrar filtros
Borrar filtros

Sharing Data between two GUIs

1 visualización (últimos 30 días)
John
John el 27 de Sept. de 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

Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Sept. de 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 comentarios
Walter Roberson
Walter Roberson el 27 de Sept. de 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 el 28 de Sept. de 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!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by