I'm dabbling with creating GUIs in Matlab. I'm trying to create a very simple GUI
that consists of a slider and a text box. What I would like to do is for the slider
to update the value of the text box and the text box to update the position of
the slider.
I'm able to retrieve the data from the text box and slider with the get(hObject,
'Value') function in their respective callback functions, but I do not know how to
trigger the update. How do I update the value of the textbox in the slider
callback function? and vice versa?
Hi, thanks for that component. But that's not what I'm looking for. I'm a novice
to the whole GUI thing and was looking for a way to do it programmatically and
not resort to using someone else's component. The reason I want to do this is to
get a feel for the GUI API in Matlab.
"Phil Goh" <pgnator@googlemail.com> wrote in message
<fbhmt4$86u$1@fred.mathworks.com>...
> "Jerome Briot" <dutmatlab@yahoo.fr> wrote in message <fbhkhv$rtg
> $1@fred.mathworks.com>...
> > Hi,
> >
> > use sliderPanel from the FEX :
> >
> > http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
> objectId=13845&objectType=file
> >
> > Jérôme
>
>
> Hi, thanks for that component. But that's not what I'm looking for. I'm a
novice
> to the whole GUI thing and was looking for a way to do it programmatically
and
> not resort to using someone else's component. The reason I want to do this
is to
> get a feel for the GUI API in Matlab.
>
> Thanks
> Phil
What about something like this:
(in the edit callback)
textValue = str2num( get(editHandle,'String') )
set(sliderHandle,'Value',textValue)
(in the slider callback)
sliderValue = num2str( get(sliderHandle,'Value') )
set(editHandle,'String', sliderValue)
> What about something like this:
>
> (in the edit callback)
> textValue = str2num( get(editHandle,'String') )
> set(sliderHandle,'Value',textValue)
>
> (in the slider callback)
> sliderValue = num2str( get(sliderHandle,'Value') )
> set(editHandle,'String', sliderValue)
>
> Is that what you're looking for?
> Lorenzo
That is similar to what I've ended up doing. I store the hObjects of the slider
and edit box in the handle in their respective CreateFcn. This didn't work
before and hence my post, but since then I've discovered I need to insert a
call to guidata, which updates the value of handle.
The plt slider object combines 3 things, the slider,
the edit box, and (optionally) a slider label, which
is often needed when there are multiple sliders or other
controls.
The plt slider also provides many modes of operation, even
including a logarithmic movement mode (in case you just want
to allow powers of 2 as an example).
I see that you want to program it yourself, although you
may get some good ideas from plt.
I would like to have a sliderPanel like the "main" one in Bretts example with an additional feature: when I use the first slider and put the slider to the value of 15 then the second slider should start with 16.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.