Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!t39g2000prh.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:28:32 -0800 (PST)
Organization: http://groups.google.com
Lines: 102
Message-ID: <a81ee8e4-32e3-4e88-b5a1-9d5af17cf337@t39g2000prh.googlegroups.com>
References: <a6b98772-2bb0-4a16-932a-918c1d1cf1c8@k19g2000yqg.googlegroups.com> 
	<see-3BB475.11194611122008@news.frontiernet.net> <f7982d81-9425-48e2-bb0b-b0732ef47b5f@p29g2000vbn.googlegroups.com>
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 1229020112 18267 127.0.0.1 (11 Dec 2008 18:28:32 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 11 Dec 2008 18:28:32 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: t39g2000prh.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:506388


On Dec 11, 1:17=A0pm, ImageAnalyst <imageanal...@mailinator.com> wrote:
> 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 pix=
els.
> > % =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. =A0Works like a charm. =A0One additional note, to get rid of
> the waitbar, delete the handle:
> =A0 =A0 =A0 =A0 % Get rid of the waitbar.
> =A0 =A0 =A0 =A0 delete(hWaitBar);
> I originally tried to set the visibility to "off" but that didn't
> work. =A0So 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.- Hid=
e quoted text -
>
> - Show quoted text -

---------------------------------------
An additional note:  because my main GUI had units of "normalized" so
that everything would scale properly if the user maximized the window,
the waitbar no longer was in the correct place if they did that
(because the units were pixels).  I tried changing the units of the
axes to "normalized" after they it was created but it still left the
waitbar in the wrong place after maximizing.  So I changed the units
to normalized when it was created with the axes command, and again
found the position by placing a "normalized-units" scrollbar in the
location that I wanted the waitbar, and then everything was fine.  It
was in the right place when the window first came up and in the right
place after the GUi was maximized.
Thanks!