[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] [ANN] Mac::Utils::ProgressBar



I sat down last night and decided that 'twas a good time to play with the
progress bar module that I mentioned here recently, so here I am a good bit
later with a working version.  You can grab a copy of
Mac::Utils::ProgressBar at
<http://www.stanford.edu/~ejalbert/software/ProgressBar.sit>.

Some basic documentation is included in the ReadMe with the download (I'm
not quite up to figuring out pod syntax after coding all night), but here's
a quick overview:  It's an all-Perl progress bar window that's
Appearance-savvy.  In other words, you don't need the Progress Bar 1.01
compiled AppleScript that goes along with Mac::Apps::PBar, and you now have
something that looks nice under MacOS 8 and later (actually, I've only
tested it under OS 8.5; please let me know if there are problems with
earlier systems).  In quick tests, it seemed to be about 50% faster than
Mac::Apps::PBar.

Why Mac::Utils?  Because everything else in the Mac:: hierarchy seems to be
a Toolbox interface module, which this one isn't (it uses those, but it
doesn't add to them), and it's a Mac-specific utility.  I'm open to other
suggestions, though....

Feel free to provide comments on the source code; while I'm comfortable
with Perl, I certainly don't know much about what would or would not be
good Perl style, and I'm likely to miss a lot of shortcuts that'll come
easily to more experienced programmers.

BTW, here's a quick sample program that runs an installer's progress bar
from 0 to 100% (it's included with the download):

#!perl

use Mac::Utils::ProgressBar;
use Mac::Events;

my $min=0;
my $max=100;

my $progressBar=new Mac::Utils::ProgressBar('Progress Bar');
$progressBar->configure(-header=>'Installing...', -text=>'Text',
-min=>$min, -max=>$max);
my $i=$min;
while($progressBar->inProgress()) {
	$progressBar->setValue($i++);
	$progressBar->setText(int (($i-$min)*100/($max-$min))."% done");
	WaitNextEvent();
}

-Eric

P.S. to those who are still reading: This module doesn't support a progress
bar's indeterminate state because there's no SetControlData function in
Controls.pm.  Are there any plans to add this?  It seems a bit of a strange
omission, but then again, I don't know all that much about the Toolbox....

--
Eric Albert                     ejalbert@cs.stanford.edu
http://www.stanford.edu/~ejalbert/

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch