Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Programmatic GUI pushbutton callback
Date: Thu, 26 Jun 2008 15:55:03 +0000 (UTC)
Organization: Purdue University
Lines: 27
Message-ID: <g40e4n$aiq$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 1214495703 10842 172.30.248.37 (26 Jun 2008 15:55:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 26 Jun 2008 15:55:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1426608
Xref: news.mathworks.com comp.soft-sys.matlab:476006




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?