Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!p29g2000vbn.googlegroups.com!not-for-mail
From: ImageAnalyst <imageanalyst@mailinator.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Putting a progress bar on a GUI - sorry, you're out of luck
Date: Thu, 11 Dec 2008 10:17:05 -0800 (PST)
Organization: http://groups.google.com
Lines: 79
Message-ID: <f7982d81-9425-48e2-bb0b-b0732ef47b5f@p29g2000vbn.googlegroups.com>
References: <a6b98772-2bb0-4a16-932a-918c1d1cf1c8@k19g2000yqg.googlegroups.com> 
	<see-3BB475.11194611122008@news.frontiernet.net>
NNTP-Posting-Host: 192.44.136.113
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1229019426 16604 127.0.0.1 (11 Dec 2008 18:17:06 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 11 Dec 2008 18:17:06 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: p29g2000vbn.googlegroups.com; posting-host=192.44.136.113; 
	posting-account=0rLUzAkAAABojYSRC64DkTbtiSCX77HH
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET 
	CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 
	3.5.21022),gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 bdci2px (NetCache NetApp/6.0.7)
Xref: news.mathworks.com comp.soft-sys.matlab:506384


On Dec 11, 11:19=A0am, Doug Schwarz <s...@sig.for.address.edu> wrote:
> In article
> <a6b98772-2bb0-4a16-932a-918c1d1cf...@k19g2000yqg.googlegroups.com>,
>
> =A0ImageAnalyst <imageanal...@mailinator.com> wrote:
> > How can I put a progress bar onto my own custom =A0GUI?
>
> Come on, you could have written it in barely more time than it took you
> to rant. =A0Okay, sometimes it's feels good to rant. =A0:-)
>
> Anyway, I wrote this for you. =A0Merry Christmas or <insert preferred
> holiday here>!
>
> function h =3D uiwaitbar(varargin)
> %uiwaitbar: A waitbar that can be embedded in a GUI figure.
> % =A0Syntax:
> % =A0 =A0POSITION =3D [20 20 200 20]; =A0% Position of uiwaitbar in pixel=
s.
> % =A0 =A0H =3D uiwaitbar(POSITION);
> % =A0 =A0for i =3D 1:100
> % =A0 =A0 =A0 =A0uiwaitbar(H,i/100)
> % =A0 =A0end
>
> % written by Doug Schwarz, 11 December 2008
>
> if ishandle(varargin{1})
> =A0 =A0 ax =3D varargin{1};
> =A0 =A0 value =3D varargin{2};
> =A0 =A0 p =3D get(ax,'Child');
> =A0 =A0 x =3D get(p,'XData');
> =A0 =A0 x(3:4) =3D value;
> =A0 =A0 set(p,'XData',x)
> =A0 =A0 return
> end
>
> pos =3D varargin{1};
> bg_color =3D 'w';
> fg_color =3D 'r';
> h =3D axes('Units','pixels',...
> =A0 =A0 'Position',pos,...
> =A0 =A0 'XLim',[0 1],'YLim',[0 1],...
> =A0 =A0 'XTick',[],'YTick',[],...
> =A0 =A0 'Color',bg_color,...
> =A0 =A0 'XColor',bg_color,'YColor',bg_color);
> patch([0 0 0 0],[0 1 1 0],fg_color,...
> =A0 =A0 'Parent',h,...
> =A0 =A0 'EdgeColor','none',...
> =A0 =A0 'EraseMode','none');
>
> --
> Doug Schwarz
> dmschwarz&ieee,org
> Make obvious changes to get real email address.

--------------------------------------------------
Thanks Doug.  Works like a charm.  One additional note, to get rid of
the waitbar, delete the handle:
	% Get rid of the waitbar.
	delete(hWaitBar);
I originally tried to set the visibility to "off" but that didn't
work.  So I tried deleting the handle and that works.

It was a little bit of work to get it positioned correctly - not as
easy as just dragging it out in GUIDE - but I did get it where I
wanted by first placing a scroll bar on the figure, changing the units
property from characters to pixels (even though my figure was
normalized), noting the "position" property of the scroll bar, and
copying that to your POSITION variable.

I wasn't familiar with the "patch()" command, so I guess sometimes
ranting does get good results - much faster than waiting for the new
GUIDE, which they've been working on for quite a while with no
announced ETA (hopefully it will be a major improvement over these
tiny little interim improvements they've been making with the MATLAB
releases).

Thanks again,
ImageAnalyst
P.S. It would still be nice if such a control were built into GUIDE.