in reply to Tk::DirTree & Win

To solve similar problem, I add following lines into my code:
if ($^O eq 'MSWin32') { require 'Win32API::File'; my @drv = map{s/\\$//;lc} Win32API::File::getLogicalDrives(); $dt->add_to_tree($_, $_) for @drv; }
where my $dt = $dirlist->Scrolled('DirTree',....

Also, to behave good on Win32, I override 'has_subdir':

package Tk; sub has_subdir {1}
and you will not get annoying behaviour, when before opening a window each drive will be tryed to access, causing by CD-ROM, diskette to roll, and slow network drives to slow down your program.

Warmest wishes,
Vadim

Replies are listed 'Best First'.
Re: Re: Tk::DirTree & Win
by vkonovalov (Monk) on May 30, 2002 at 11:07 UTC
    correction: I override 'has_subdir' in Tk::DirTree package.
    Also there is some more to override in those packages for Win32 (for case-insensistive sorting, for exampe):
    package ::Tk::DirTree; sub has_subdir {1} sub DirCmd { my ($w, $dir, undef) = @_; $dir =~ s/^(\w:)$/$1\//; my $h = DirHandle->new($dir) or return; my @names = grep( $_ ne '.' && $_ ne '..', $h->read ); return @names; } sub add_to_tree { my( $w, $dir, $name, $parent ) = @_; my $image = $w->Getimage( $w->cget('-image') ); my $mode = 'none'; $mode = 'open' if $w->has_subdir( $dir ); my @args = (-image => $image, -text => $name); if( $parent ) { # Add in alphabetical order. foreach my $sib ($w->infoChildren( $parent )) { if( lc($sib) gt lc($dir) ) { push @args, (-before => $sib); last; } } } $w->add( $dir, @args ); $w->setmode( $dir, $mode ); }
      thanx i'll give it a shut

      ----
      NaSe
      :x