Question on GUI's

Question on GUI's

Post by John » Sat, 09 Jul 2005 05:23:15


I am trying to create a GUI without using GUIDE. I have my function
that defines the uicontrol

uicontrol('style','listbox','Units','Characters','pos',[220 55 25
15],...

'Max',5,'tag','listbox','String',varname,'Callback','Data_Callback');

then i have my callback function

function [var1,var2] = Data_Callback(h,event,handles)
selected = get(handles.listbox,'Value')
name = get(handles.listbox,'String');
x = name{selected}

i just want to know what i have to do in order for it to determine
what is selected and place it under a variable. I am trying to do
this because VARNAME is the data that i am going to constantly change
to update the listbox.
 
 
 

Question on GUI's

Post by Tanner Sut » Sat, 09 Jul 2005 05:35:50

I cant offer much help... but why dont you want to use guide?

 
 
 

Question on GUI's

Post by Steve Simo » Sat, 09 Jul 2005 05:43:07


If you aren't using GUIDE, then you will need to do some additional
setup to get this to work. The Callback should be:

'Data_Callback(gcbo)'

and the function itself should be:

function [var1,var2] = Data_Callback(h)
selected = get(h,'Value')
name = get(h,'String');
x = name{selected}


Take a look at the actual values for the Callback property in GUIDE.
The expressions that correspond to 'h', 'eventdata', and 'handles', in
the callback function inputs, are 'gcbo','[]', and 'guidata(gcbo)'.
GCBO will return the handle for the current callback object, i.e.
whatever you just clicked on. The 'eventdata' will be an empty array.
GUIDATA(GCBO) returns a variable stored at a particular location in the
figure's application data. This variable (the 'handles' structure) is
usually created somewhere in the GUI's startup code. Since you aren't
using GUIDE, you probably don't have this variable. You could create it
by calling:

guidata(figure_handle,guihandles(figure_handle))

-SteveSimon-
 
 
 

Question on GUI's

Post by John » Sat, 09 Jul 2005 21:49:44

Thank you very much Steve it worked like a charm.