Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Programmatic GUI pushbutton callback
Date: Thu, 26 Jun 2008 17:46:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 69
Message-ID: <g40kkq$rah$1@fred.mathworks.com>
References: <g40e4n$aiq$1@fred.mathworks.com> <g40jj2$f7m$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1214502362 27985 172.30.248.37 (26 Jun 2008 17:46:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 26 Jun 2008 17:46:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 939004
Xref: news.mathworks.com comp.soft-sys.matlab:476055



"Kris Ezra" <sharpshooter1405@yahoo.com> wrote in message
<g40jj2$f7m$1@fred.mathworks.com>...
> "Kris Ezra" <sharpshooter1405@yahoo.com> wrote in message 
> <g40e4n$aiq$1@fred.mathworks.com>...
> > 
> > I am building a GUI to interface with a MATLAB model and, 
> > in the interest of maintaining GUI variables in the 
> > workspace and accessible, I have opted to create it 
> > programmatically and not in function form instead of with 
> > GUIDE.
> > 
> > The problem I have is that, while I can easily create the 
> > GUI and push buttons with code like
> > 
> > startbutton = 
> > uicontrol(panel3,'Style','pushbutton','String','Create 
> > Scenario',...
> >     'Position',[40, 80, 120, 40], 'BackgroundColor', 
> > [0.8,0.8,0.8]);  
> > 
> > I cannot find any way to set the button callback.  I 
> would 
> > rather not use custom functions (which shouldnt matter 
> > since the main GUI is just written in a script file) and 
> I 
> > cant find a solution.
> > 
> > As a simple test, I would like to have "startbutton" open 
> a 
> > PDF file.
> > 
> > I have tried something to the effect of set
> > (startbutton, 'Callback', open usersguide.pdf) but this 
> > does not work.  What else can I do to code button 
> callbacks?
> 
> 
> The idea of keeping the callback in single quotes 
> definitely worked for this specific example; however, 
> because I'm writing the gui in a script file I cannot 
> define functions at the end so the second idea is out.  Is 
> there another option besides creating custom external 
> functions for EVERY uicontrol item I write (besides some 
> complicated flagging system that I could write to do the 
> functionality?
> 
> I would like to find a way to do callbacks contained in the 
> script file that conduct lengthy operations.  For example, 
> I may have a next button that calls a giant switch to see 
> what panels to set as visible or invisible wich I would 
> rather not have to put in single quotes inside the button 
> definition :).
> 
> Thanks!
> 
> Kris 

Well I don't know about that, but is there any reason you
can't turn your script file into a function file just by
putting the line:

function myguiname

at the top? That would let you define more functions in the
file at the end. I do this all the time. But even with the
script I think you should be able to do what I said and just
put the callbacks in functions in their own, separate files.