You're right, of course. It's not quite as straight-forward as I was thinking it would be. :)
The problem is that you need a hook into the default handler for the dircmd callback, and it doesn't seem that you can get one. You're probably going to need to write your own. :(
Here is the source of the default handler (taken directly from Tk/DirTree.pm):
sub DirCmd {
my( $w, $dir, $showhidden ) = @_;
my $h = DirHandle->new( $dir ) or return();
my @names = grep( $_ ne '.' && $_ ne '..', $h->read );
@names = grep( ! /^[.]/, @names ) unless $showhidden;
return( @names );
}
Pretty simple. You just need to include a modified version of that sub in your program, and give your Tk::DirTree object a reference to it as the handler for the -dircmd callback (ie, $dirtree->configure(-dircmd => \&MyDirCmd);).
In your copy, you need to break out that grep, probably into a for loop, or something, so that you can have your code update the Tk::ProgressBar. Of course, that's going to slow down reading of all directories. Not by much, though, hopefully.
Anyway, regarding showing and hiding the progress bar... You could use a pop-up window to show it (there's even a Tk::ProgressBarDialog or something similar in the Snippets section of this site, I believe). I, however, would probably go with a status-bar type deal, where the progress bar is always shown, but empty, at the bottom of the window, and it just fills up while reading directories. *shrug* Up to you.
Hope that helps!
bbfu
Black flowers blossum
Fearless on my breath |