Re: Displaying results in GUI
- From: "Mark Wiley" <maquereau66@xxxxxxxxx>
- Date: Mon, 29 Aug 2005 16:45:49 -0400
Ok so my understanding is that you have a function that you've
written that returns a numerical result which you want to display in
a gui. At some point you need to signal to your gui to do the
computation and display the result. There are a few ways you can do
this. I'll describe two which I use most often. One way is in the
gui's opening function ( called guiName_OpeningFcn(hObject,
eventdata, handles, varargin) ). Here you can call your function and
display the result as soon as the gui loads. Or, you could use a
button in the gui which tells the gui to do your process and display
the result.
Let's say we've set up the gui as follows:
We have a textbox whose tag property is: textbox
We have a pushbutton whose tag property is: btnGo
We have named the function you wish to call: foo()
Now you would add this to the body of the opening function should you
choose to execute the command and display the results as soon as the
gui loads:
set(handles.textbox, 'String', foo());
or if you need to use foo's result later on:
result = foo();
set(handles.textbox, 'String', result);
If you choose to do the computation and display upon the pushing of a
button, you would need this code to appear:
function btnGo_Callback(hObject, eventdata, handles)
result = foo();
set(handles.textbox, 'String', result);
I hope this helps.
Regards
Mark
Nevine Jacob wrote:
>
>
> I have an M-file (implemented for GUI) which produces a certain
> result (numerical result) when run. I would like to display this
> result on the GUI. How do I do it?
>
> I created a "edit text" component and tried displaying the result
> to
> this component. However, the result is not displayed automatically.
> I
> need to delete the 'default string' of the edit text box in order
> to
> see the result. I am fairly new to Matlab GUI. I would be glad if
> someone could help me out.
>
> ****************************
>
> Here's the section of code:
>
> function textbox_Callback(hObject, eventdata, handles)
> % hObject handle to text17 (see GCBO)
> % eventdata reserved - to be defined in a future version of MATLAB
> % handles structure with handles and user data (see GUIDATA)
>
> % Hints: get(hObject,'String') returns contents of text17 as text
> % str2double(get(hObject,'String')) returns contents of
> text17
> as a double
>
> set(hObject,'BackgroundColor','white');
> set(hObject,'String',value);
>
> ********************
>
> Thanks,
> Nevine
.
- References:
- Displaying results in GUI
- From: Nevine Jacob
- Displaying results in GUI
- Prev by Date: 2 Qus : (1) fminsearch (2) figures to word
- Next by Date: Out of memory problem
- Previous by thread: Re: Displaying results in GUI
- Next by thread: Mapping image
- Index(es):
Loading