Path: news.mathworks.com!not-for-mail
From: "ching l" <chinglnc@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Gui Pushbutton default
Date: Tue, 21 Jul 2009 15:09:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 82
Message-ID: <h44lmd$qii$1@fred.mathworks.com>
References: <h42ns9$kun$1@fred.mathworks.com> <14ea2dbd-e56d-4b48-8fdc-39b0060a5ee4@p36g2000prn.googlegroups.com> <h43und$mqu$1@fred.mathworks.com> <h44ele$30a$1@fred.mathworks.com>
Reply-To: "ching l" <chinglnc@hotmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1248188941 27218 172.30.248.37 (21 Jul 2009 15:09:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 21 Jul 2009 15:09:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1438759
Xref: news.mathworks.com comp.soft-sys.matlab:557172


"Andy Eisenberg" <theorigamist@gmail.com> wrote in message <h44ele$30a$1@fred.mathworks.com>...
> "ching l" <chinglnc@hotmail.com> wrote in message <h43und$mqu$1@fred.mathworks.com>...
> > Nathan <ngreco32@gmail.com> wrote in message <14ea2dbd-e56d-4b48-8fdc-39b0060a5ee4@p36g2000prn.googlegroups.com>...
> > > On Jul 20, 2:34?pm, "ching l" <ching...@hotmail.com> wrote:
> > > > Hello there,
> > > >
> > > > How do I set the pushbutton off by default?
> > > > This is what I've tried but apparently that isn't right.
> > > >
> > > > -----------------------------------------------------------
> > > > function next_Callback(hObject, eventdata, handles)
> > > >
> > > > handles = guidata(gcbo);
> > > >
> > > > set(hObject, 'enable', 'off')
> > > >
> > > > guidata(gcbo, handles);
> > > >
> > > > ------------------------------------------------------------
> > > >
> > > > Please advise.
> > > >
> > > > Thanks.
> > > 
> > > What do you mean by "off"? Do you mean disabled, or do you mean
> > > invisible?
> > > In either case...
> > > Let's say your push button tag is pushbutton1
> > > 
> > > To disable it:
> > > set(handles.pushbutton1,'Enable','off')
> > > 
> > > To make it invisible:
> > > set(handles.pushbutton1,'Visible','off')
> > > 
> > > Either of those should work.
> > > -Nathan
> > 
> > Hello, my push button tag is set to next. 
> > 
> > my codes are, 
> > 
> > function next_Callback(hObject, eventdata, handles)
> > 
> > set(handles.next,'Enable','off')
> > 
> > but it doesn't seem to work.
> > 
> > Did i miss out anything?
> 
> The following works for me (saved as test.m):
> 
> function test
>     f=figure('Units','normalized',...
>         'Position',[.4 .4 .2 .2],...
>         'Visible','on');
> 
>     push1=uicontrol('Style','pushbutton',...
>         'Parent',f,...
>         'Units','characters',...
>         'Position',[5 2 20 2],...
>         'Callback',{@push1_Callback},...
>         'String','Disable');
> 
>     function push1_Callback(src,eventdata)
>         set(push1,'Enable','off');
>     end
> end
> 
> Can you say a little bit more about what exactly went wrong?

THANKS A LOT FOR THAT!! your codes worked!

I didn't really create the gui by "codes", instead i created the Gui by Guide Quickstart, then drag the pushbutton from the menu to the build window etc, it will then save in m-file and fig. But theoretically it should be the same?

so inside the m-file, in the next_Callback function, I inserted the codes as above. 
However,when I saved it and opened the fig file, it still remains enable. Anyway, I managed to set it as "default disable" by double click on the pushbutton and disable it on the ENABLE menu (setting as "off").

I still don't understand why your codes don't work in this way, isn't it should be the same?