Thread Subject: modify pushbutton caption

Subject: modify pushbutton caption

From: Yana Myronovych

Date: 17 Jan, 2008 13:35:03

Message: 1 of 4

I've created a figure with GUI, so m-file was created
automatically. The figure contains 2 buttons. The caption
of one button has to be changed by clicking on this button.
How can I do this. I've tried:

function pushbutton1_Callback(hObject, eventdata, handles)

set (pushbutton1, 'String', 'Button's name')

but I become an error: Undefined function or
variable 'pushbutton1'.
So, what is the correct way to do this?
Thanks for help


Subject: modify pushbutton caption

From: Ian Clarkson

Date: 17 Jan, 2008 14:21:01

Message: 2 of 4

"Yana Myronovych" <yana_myronovych@web.de> wrote in message
<fmnli6$bp2$1@fred.mathworks.com>...
> I've created a figure with GUI, so m-file was created
> automatically. The figure contains 2 buttons. The caption
> of one button has to be changed by clicking on this
button.
> How can I do this. I've tried:
>
> function pushbutton1_Callback(hObject, eventdata, handles)
>
> set (pushbutton1, 'String', 'Button's name')
>
> but I become an error: Undefined function or
> variable 'pushbutton1'.
> So, what is the correct way to do this?
> Thanks for help
>
>

You need to call 'set' on the HANDLE to the pushbutton, I
believe. Assuming the tag for the push button is actually
pushbutton1 (you can check this in GUIDE), try:

set(handles.pushbutton1,'String','Button Name');

Subject: modify pushbutton caption

From: Anh Huy Phan

Date: 17 Jan, 2008 14:30:19

Message: 3 of 4

"Ian Clarkson" <ian.clarkson@gesturetek.com> wrote in
message <fmno8d$fvu$1@fred.mathworks.com>...
> "Yana Myronovych" <yana_myronovych@web.de> wrote in
message
> <fmnli6$bp2$1@fred.mathworks.com>...
> > I've created a figure with GUI, so m-file was created
> > automatically. The figure contains 2 buttons. The
caption
> > of one button has to be changed by clicking on this
> button.
> > How can I do this. I've tried:
> >
> > function pushbutton1_Callback(hObject, eventdata,
handles)
> >
> > set (pushbutton1, 'String', 'Button's name')
> >
> > but I become an error: Undefined function or
> > variable 'pushbutton1'.
> > So, what is the correct way to do this?
> > Thanks for help
> >
> >
>
> You need to call 'set' on the HANDLE to the pushbutton, I
> believe. Assuming the tag for the push button is actually
> pushbutton1 (you can check this in GUIDE), try:
>
> set(handles.pushbutton1,'String','Button Name');

In this case, you can use this code

   set(hObject,'String','Button Name');

because hObject is handle of pushbutton1.

Anh Huy Phan
RIKEN - BSI

Subject: modify pushbutton caption

From: Yana Myronovych

Date: 17 Jan, 2008 14:34:02

Message: 4 of 4

It works!
Thanks a lot!

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

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.

Contact us at files@mathworks.com