|
"Gautam Vallabha" <gvallabh@mathworks.com> wrote in message
<f7lgrm$114$1@fred.mathworks.com>...
> Another way is to modify the outputs of the GUI (I assume
you are using a
> "modal question" GUI). If your gui name is "mygui", then:
>
> 1) In mygui.m, find mygui_OutputFcn.
>
> 2) Gather the data you want to output.
> s.name = get(handles.edit1, 'String');
> s.age = str2num(get(handles.edit2, 'String'));
> s.genderID = get(handles.listbox1, 'value');
>
> 3) Assign the structure to varargout
> varargout{1} = s;
>
> Now, invoke your GUI like this:
> >> out = mygui
> and you will get your structure s as the output.
>
> --
>
> Gautam Vallabha
> The MathWorks
> Email: Gautam.Vallabha@mathworks.com
>
>
I have a very similar problem I'm looking for a
solution as well. In my case, I understood that I have to
use uiwait in the _OpeningFcn function to hold MATLAB
command line and wait fot the user to set values on the GUI.
My code is like:
% Code start
function xxx_OpeningFcn(hObject, eventdata, handles,
varargin)
uiwait(handles.figure1);
function figure1_CloseRequestFcn(hObject, eventdata,
handles)
uiresume();
delete(hObject);
function varargout = xxx_OutputFcn(hObject, eventdata,
handles)
varargout{1} = handles.output;
<somewhere in the code>
handles.output=data;
guidata(handles.figure1,handles);
% Code end
This does not work, though. Apparently, when the _OutputFcn
is invoked after having closed the window, the "handles"
have already been destroyed. In fact, it results to me that
the variable "handles" in _OutputFcn is empty.
The _CloseRequestFcn is actually executed before the
_OutputFcn, but for some reason uiresume does not do the
job, and when _OutputFcn is called, the figure has already
been killed and all the handles and data lost.
Can someone help, please? Many thanks.
Matteo
|